Decoding method, device and equipment for huffman coding image based on maximum code word

By distinguishing the data to be decoded and determining the actual code length during the decoding process of JPEG format images, the problem of low Huffman decoding efficiency is solved, and a more efficient decoding process is achieved.

CN115695823BActive Publication Date: 2025-12-16ZHUHAI JIELI TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210648386.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-09
Publication Date
2025-12-16
Estimated Expiration
2042-06-09

AI Technical Summary

Technical Problem

Existing technologies for decoding JPEG format images suffer from low Huffman decoding efficiency, especially due to the large number of invalid comparisons during bit-by-bit reading of the data to be decoded, resulting in low decoding efficiency.

Method used

By distinguishing the data to be decoded, it is determined whether it is a polysemous character. If it is not a polysemous character, it is compared with the maximum extended codeword value to determine the true code length and reduce the number of invalid comparisons. If it is a polysemous character, it is decoded in a specific way.

Benefits of technology

It improves the decoding efficiency of Huffman-coded images, reduces the number of invalid comparisons during the decoding process, and enhances decoding speed and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115695823B_ABST
    Figure CN115695823B_ABST
Patent Text Reader

Abstract

The application provides a decoding method, device and equipment for a Huffman coded image based on a maximum code word, wherein whether the current group of data to be decoded in a data buffer is a polysemous word is judged, if not, the current group of data to be decoded is compared with each maximum extended code word value in turn, if the current group of data to be decoded is less than or equal to a first maximum extended code word value, a first real code length corresponding to the first maximum extended code word value is found in a mapping relationship, and bit data with the first real code length is read from the current group of data to be decoded as a first Huffman code word. In the embodiment of the application, the data to be decoded is first distinguished, the real code length of the current group of data to be decoded is determined after it is determined that the data to be decoded is not a polysemous word, the number of invalid comparison times in the decoding process is reduced, and the decoding efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of image processing, and in particular to a decoding method, device and equipment for Huffman coded image based on maximum code word. BACKGROUND

[0002] In the process of JPEG format image decoding, a key step is Huffman decoding, which determines the image decoding efficiency. Huffman coding is variable length coding, which constructs code word with the shortest average length of different prefixes according to character occurrence probability. The higher the probability of character occurrence, the shorter the length of corresponding Huffman coding. In the process of Huffman decoding, since the actual code length is unknown, the decoding is usually performed by reading the to-be-decoded data bit by bit (hereinafter referred to as bit-by-bit decoding), that is, one bit of the to-be-decoded data is read each time, and x bits B1B2…Bx are added to form B1B2…Bx+1 as a whole, and then the same code word is searched in the Huffman coding table. If found, the B1B2…Bx+1 is the actual code word of the to-be-decoded data, and x+1 is the code length of the to-be-decoded data; if not found, the x+2 bit Bx+2 of the to-be-decoded data is read and added to the x bits B1B2…Bx to form B1B2…Bx+2 as a whole, and then the same code word is searched in the Huffman coding table. x B x B x+1 Then the same code word is searched in the Huffman coding table. x B x+1 B x B x+1 If found, the B1B2…Bx+1 is the actual code word of the to-be-decoded data, and x+1 is the code length of the to-be-decoded data; if not found, the x+2 bit Bx+2 of the to-be-decoded data is read and added to the x bits B1B2…Bx to form B1B2…Bx+2 as a whole, and then the same code word is searched in the Huffman coding table. X+2 B x B x+1 B x B x+1 B x+2 Then the same code word is searched in the Huffman coding table. x B x+1 B x+2 Usually, each code length corresponds to multiple code words (for example, the code length of 2 has 00 and 01), in order to realize decoding, if the code word is compared with the corresponding bit number of the to-be-decoded data from the code word with small code length one by one, the decoding efficiency is low.

[0003] In order to improve the decoding efficiency, the prior art proposes a technical solution: comparing the fixed length to-be-decoded data with the minimum code word extension value corresponding to each code length respectively, when the to-be-decoded code word is smaller than the minimum code word extension value corresponding to any one of the code lengths, determining the effective code length of the to-be-decoded code word, and according to the effective code length, searching the decoding code word corresponding to the effective code length from the corresponding relationship between the code length and the decoding code word, to realize the decoding scheme, however, the efficiency of this scheme still has room for improvement. SUMMARY

[0004] Based on the above status, the main purpose of the present application is to provide a decoding method, device and equipment of Huffman coded image, first distinguishing the to-be-decoded data, determining that it is not a polysemy word, and then determining the real code length of the current group of to-be-decoded data, reducing the number of invalid comparisons in the decoding process, and improving the decoding efficiency.

[0005] To achieve the above purpose, the technical scheme adopted by the present application is as follows:

[0006] A Huffman coded image method based on maximum code word, comprising the following steps: S100, filling 1 to a set length on the right side of all maximum Huffman code words with code length not greater than the set length to obtain a plurality of maximum expansion code word values, and establishing a mapping relationship between each maximum expansion code word value and the corresponding real code length; buffering a plurality of groups of to-be-decoded data in a data buffer area, wherein the length of each group of to-be-decoded data is the set length, judging whether the current group of to-be-decoded data in the data buffer area is a polysemy word, if not, executing S200, if yes, executing S300; S200, comparing the current group of to-be-decoded data with one of the plurality of maximum expansion code word values in turn, if the current group of to-be-decoded data is less than or equal to a certain maximum expansion code word value, stopping the comparison, taking the certain maximum expansion code word value as a first maximum expansion code word value, and finding a first real code length corresponding to the first maximum expansion code word value in the mapping relationship, reading bit data with a length of the first real code length from the current group of to-be-decoded data as a first Huffman code word; S300, decoding in a manner different from S200 according to the real meaning of the polysemy word.

[0007] Preferably, the S300 comprises judging whether the next group of to-be-decoded data is a hexadecimal value 00; if yes, judging that the real meaning of the polysemy word is a component of the Huffman code word, and starting to decode bit by bit from the Kth bit of the to-be-decoded data composed of the current group of to-be-decoded data and the next group of to-be-decoded data; wherein K is equal to the set length plus 1; if not, judging that the real meaning of the polysemy word is a component of the marker code, and composing a marker code with the polysemy word and the next group of to-be-decoded data, and decoding according to the real meaning of the marker code.

[0008] Preferably, the S200 is followed by the following steps: S400, finding a decoding value corresponding to the first Huffman code word, and parsing the decoding value to obtain a first bit length; S500, reading bit data with the first bit length from the data buffer area after the first Huffman code word as quantization value data of the decoding value.

[0009] Preferably, after the step S500, the method further comprises the following steps: S600, if the sum of the real code length of the first Huffman code word and the first bit length is not equal to an integer multiple of the set length, determining whether the next group of to-be-decoded data after the bit data of the first bit length in the data buffer is the ambiguous word, and if not, performing a step S700; S700, reading the set length of to-be-decoded data from the (M+N+1)th bit in the data buffer starting from the first bit data of the current group of to-be-decoded data to form cross-group to-be-decoded data, wherein M is the first real code length and N is the first bit length; comparing the cross-group to-be-decoded data with one of the plurality of maximum extension code word values in sequence, stopping the comparison if the cross-group to-be-decoded data is less than or equal to a certain maximum extension code word value, taking the certain maximum extension code word value as a second maximum extension code word value, searching for a second real code length corresponding to the second maximum extension code word value in the mapping relationship, and reading bit data of the second real code length from the cross-group to-be-decoded data as a second Huffman code word.

[0010] Preferably, in the step S600, if the next group of to-be-decoded data is the ambiguous word, a step S800 is performed; S800, bit data between the bit data of the first bit length and the next group of to-be-decoded data is decoded bit by bit starting from the (M+N+1)th bit in the data buffer starting from the first bit data of the current group of to-be-decoded data.

[0011] Preferably, the mapping relationship comprises a first sub-mapping relationship and a second sub-mapping relationship, the first sub-mapping relationship is a relationship between the maximum extension code word value and an index, the second sub-mapping relationship is a relationship between the index and the real code length, and the searching for the first real code length corresponding to the first maximum extension code word value in the mapping relationship comprises: S210, searching for an index of the first maximum extension code word value corresponding to the current group of to-be-decoded data in the first sub-mapping relationship; S220, searching for the first real code length corresponding to the current group of to-be-decoded data in the second sub-mapping relationship according to the index.

[0012] Preferably, in the S400, the decoding value corresponding to the first Huffman code word is found by the following steps: S410, a first address is determined according to the first real code length, the first address is the address of the minimum Huffman code word with the code length equal to the first real code length in a Huffman coding table, the Huffman coding table is used to store the decoding value corresponding to the Huffman code word; S420, the difference between the first Huffman code word and the minimum Huffman code word is calculated as an address offset value; S430, a second address is determined by offsetting the first address by the address offset value, and the value in the second address is read as the decoding value of the first Huffman code word.

[0013] Preferably, in the S200, if the current group of to-be-decoded data is greater than any maximum extended code word value, the Kth bit of the to-be-decoded data composed of the current group of to-be-decoded data and the next group of to-be-decoded data is decoded bit by bit, where K is equal to the set length plus 1.

[0014] The application also provides a decoding device for a Huffman coded image based on a maximum code word, comprising: a buffer preparation module, which is used to fill 1 to a set length to the right of each maximum Huffman code word with a code length not greater than the set length to obtain a plurality of maximum extended code word values, and establish a mapping relationship between each maximum extended code word value and a corresponding real code length; buffer a plurality of groups of to-be-decoded data in a data buffer area, wherein the length of each group of to-be-decoded data is the set length, and determine whether the current group of to-be-decoded data in the data buffer area is an ambiguous word, if not, trigger a first decoding module to work, and if yes, trigger a second decoding module to work; the first decoding module is used to compare the current group of to-be-decoded data with one of the plurality of maximum extended code word values in turn, if the current group of to-be-decoded data is less than or equal to a certain maximum extended code word value, stop the comparison, take the certain maximum extended code word value as a first maximum extended code word value, and find a first real code length corresponding to the first maximum extended code word value in the mapping relationship, and read bit data with the length of the first real code length from the current group of to-be-decoded data as a first Huffman code word.

[0015] The second decoding module is used to decode in a manner different from the first decoding module according to the real meaning of the ambiguous word.

[0016] Preferably, the second decoding module comprises a numerical zero detection unit for judging whether the next group of to-be-decoded data is a hexadecimal numerical zero; if yes, judging that the true meaning of the ambiguous word is a component of the Huffman code word, and starting to decode bit by bit from the Kth bit of the to-be-decoded data composed of the current group of to-be-decoded data and the next group of to-be-decoded data; wherein K is equal to the preset length setting length plus 1; if no, judging that the true meaning of the ambiguous word is a component of the marker code, and composing a marker code from the ambiguous word and the next group of to-be-decoded data, and decoding according to the true meaning of the marker code.

[0017] Preferably, the method further comprises a quantization value calculation module working after the first decoding module, for searching for a decoding value corresponding to the first Huffman code word, and parsing the decoding value to obtain a first bit length; reading bit data of the first bit length from the data buffer after the first Huffman code word as quantization value data of the decoding value.

[0018] The application further provides an embedded display device for decoding a Huffman coded image by using any of the methods or comprising any of the decoding apparatuses.

[0019] The application further provides a computer readable storage medium having a computer program stored thereon, the computer program being executable to implement any of the methods.

[0020] The application further provides a decoding chip comprising a processor and a memory, the memory storing a computer program, and the processor being capable of executing the computer program to implement any of the methods.

[0021] According to the decoding method, device and equipment for a Huffman coded image based on a maximum code word disclosed by the embodiments of the application, whether the current group of to-be-decoded data in the data buffer is an ambiguous word is judged; if no, the current group of to-be-decoded data is compared with each maximum extension code word value in turn, if the current group of to-be-decoded data is less than or equal to a first maximum extension code word value, a first real code length corresponding to the first maximum extension code word value in the mapping relationship is searched for, and bit data with the first real code length is read from the current group of to-be-decoded data as a first Huffman code word. The embodiments of the application first distinguish the to-be-decoded data, determine that it is not an ambiguous word, and then determine the real code length of the current group of to-be-decoded data, so that the number of invalid comparisons in the decoding process is reduced, and the decoding efficiency is improved.

[0022] Other beneficial effects of the application will be described in the specific embodiments by introducing specific technical features and technical solutions, and those skilled in the art should be able to understand the beneficial technical effects brought by the technical features and technical solutions through the introduction of the technical features and technical solutions. Attached Figure Description

[0023] The preferred embodiments of the Huffman-coded image decoding method, apparatus, and device of the present invention will now be described with reference to the accompanying drawings. (Figures:)

[0024] Figure 1 A flowchart illustrating a Huffman-coded image decoding method based on maximum codewords according to a preferred embodiment of the present invention;

[0025] Figures 2a to 2d This is a schematic diagram of the data buffer in a Huffman-coded image decoding method based on maximum codewords according to a preferred embodiment of the present invention.

[0026] Figure 3 This is a flowchart of a decoding method for Huffman-coded images based on maximum codewords according to another preferred embodiment of the present invention;

[0027] Figure 4a This is a schematic diagram of the first sub-mapping relationship in a decoding method for Huffman-coded images based on the maximum codeword according to a preferred embodiment of the present invention.

[0028] Figures 4b to 4c This is a schematic diagram of the second sub-mapping relationship in a decoding method for Huffman-coded images based on the maximum codeword according to a preferred embodiment of the present invention.

[0029] Figure 5 This is a flowchart illustrating the decoding process of a frame of an image in a Huffman-coded image decoding method based on the maximum codeword, according to a preferred embodiment of the present invention. Detailed Implementation

[0030] The present invention is described below based on embodiments, but the present invention is not limited to these embodiments. In the following detailed description of the present invention, some specific details are described in detail, but well-known methods, processes, procedures, and elements are not described in detail in order to avoid obscuring the essence of the present invention.

[0031] Furthermore, those skilled in the art should understand that the accompanying drawings provided herein are for illustrative purposes only and are not necessarily drawn to scale.

[0032] Unless the context explicitly requires it, the words "comprising," "including," and similar terms throughout the specification and claims should be interpreted as encompassing rather than being exclusive or exhaustive; that is, meaning "including but not limited to."

[0033] In the description of the present application, it should be understood that the terms "first", "second" and the like are used only for descriptive purposes and are not to be construed as indicating or implying relative importance. In addition, in the description of the present application, the meaning of "a plurality of" is two or more, unless otherwise specified.

[0034] There can be ambiguous words representing multiple meanings in the code stream of Huffman coded image (such as image in jpeg format), for example, 0xFF (representing hexadecimal number "FF", the number starting with 0x below represents hexadecimal number), which can be a component of two-byte marker code, such as marker code 0xFFD8 representing image start bit flag, marker code 0xFFFE representing annotation, etc.; the 0xFF can also be a component of Huffman code word (i.e. the 0xFF is a component of two-byte compressed code stream generated by Huffman coding, such as 0xFF00). When decoding, if the data to be decoded is 0xFF, it is necessary to further judge whether the 0xFF is a component of marker code or a component of Huffman code word.

[0035] The present application discloses a decoding method of Huffman coded image based on maximum code word, referring to Figure 1 and Figure 2a , Figure 1 The flow chart of a decoding method of Huffman coded image in the present embodiment is shown. Figure 2a The data processing schematic in data buffer and decoder is shown, decoding in the unit of MCU (Minimum Coding Unit), assuming that there are currently 8 groups of data to be decoded, A1-A8, 4 groups of data to be decoded A1-A4 are stored in the data buffer, and the current group of data to be decoded in the decoder is A1. The length of each group of data to be decoded is a set length, which can be determined according to the probability of Huffman code word occurrence, for example, if the probability of Huffman code word with code length less than 8 bits is greater than 70%, the set length can be 8 bits, and the set length in the present embodiment is 8 bits.

[0036] The decoding method of Huffman coded image based on maximum code word disclosed in the present application comprises the following steps:

[0037] S100, obtaining a plurality of maximum expansion code word values by right filling 1 to the set length for each maximum Huffman code word with code length not greater than the set length, and establishing the mapping relationship between each maximum expansion code word value and the corresponding real code length. Buffering a plurality of groups of data to be decoded in the data buffer, wherein the length of each group of data to be decoded is a set length, judging whether the current group of data to be decoded in the data buffer is an ambiguous word, if not, executing S200, if yes, executing S300.

[0038] Specifically, each maximum extension codeword value is obtained by filling 1 to the right of the corresponding maximum Huffman codeword to a set length, the corresponding Huffman codeword refers to the maximum Huffman codeword with a real code length of n, for example, in the case of a set length of 8 bits, the real code length of 2 corresponds to the maximum Huffman codeword of 01, the maximum extension codeword value corresponding to the maximum Huffman codeword 01 is: 0111 1111; the maximum Huffman codeword of the real code length of 3 is 100, the maximum extension codeword value corresponding to the maximum Huffman codeword 100 is 1001 1111, the maximum Huffman codeword of the real code length of 8 is equal to its maximum extension codeword value, and there is no need to fill 1 to the right. The mapping relationship is the correspondence between each maximum extension codeword value and the corresponding real code length, in the above example, the maximum extension codeword value of 0111 1111 corresponds to the real code length of 2, and the maximum extension codeword value of 1001 1111 corresponds to the real code length of 3.

[0039] S200, sequentially compare the current group of to-be-decoded data with one of the plurality of maximum extension codeword values, if the current group of to-be-decoded data is less than or equal to a certain maximum extension codeword value, stop comparing, take the certain maximum extension codeword value as the first maximum codeword extension value, and find the first real code length corresponding to the first maximum codeword extension value in the mapping relationship, read the bit data with the length of the first real code length from the current group of to-be-decoded data as the first Huffman codeword.

[0040] For example, compare the current group of to-be-decoded data A1 with one of the plurality of maximum extension codeword values in order from small to large, if the current group of to-be-decoded data is less than or equal to a certain maximum extension codeword value, stop comparing, take the certain maximum extension codeword value as the first maximum extension codeword value, and find the first real code length corresponding to the first maximum extension codeword value in the mapping relationship, read the bit data with the length of the first real code length from the current group of to-be-decoded data as the first Huffman codeword.

[0041] S300, decode in a manner different from S200 according to the real meaning of the ambiguous word.

[0042] The specific decoding manner can adopt a bit-by-bit decoding manner, or other decoding manners, which are not limited here. For example, Figure 2a As shown in some embodiments, S300 includes judging whether the next group of to-be-decoded data A2 is a hexadecimal value of 00; if yes, judging that the real meaning of the ambiguous word is a component of the Huffman codeword, and starting to decode bit by bit from the Kth bit (the 9th bit) of the to-be-decoded data (0xFF72) composed of the current group of to-be-decoded data A1 and the next group of to-be-decoded data A3 (0x72); wherein K is equal to the set length plus 1. As shown in Figure 2bAs shown, if the next group of data to be decoded is not the hexadecimal value 00, it is determined that the true meaning of the ambiguous word is a component of the marker code, and the ambiguous word (0xFF) and the next group of data to be decoded (0xDB) form the marker code, and the true meaning of the marker code (0xFFDB) is decoded, for example, if the meaning of the marker code 0xFFDB is a quantization table, the process is transferred to the quantization table processing program.

[0043] In the embodiment, if the current group of data to be decoded A1 is not determined to be an ambiguous word first, but is directly decoded according to step S200, and after comparing the current group of data to be decoded A1 with all the maximum extension code word values, the first maximum extension code word value is still not found (the number of comparison times is equal to the set length), at this time, it is determined whether the current group of data to be decoded A1 is an ambiguous word and it is found that the current group of data to be decoded is a component of the marker code, not a component of the Huffman code word, then the multiple comparisons of assuming the current group of data to be decoded as a Huffman code word will become useless and redundant, that is, invalid, which is low decoding efficiency. In the actual scheme of the embodiment, it is first determined whether the current group of data to be decoded A1 in the data buffer is an ambiguous word, if not, decoding is performed according to step S200, and if it is an ambiguous word, decoding is performed according to step S300, which can effectively avoid the invalid comparison times mentioned above and improve the decoding efficiency.

[0044] As shown in Figure 3 After the first Huffman code word is determined, the decoding value corresponding to the first Huffman code word needs to be solved to determine the quantization value data corresponding to the first Huffman code word. Specifically, the following steps are included: S400, finding the decoding value corresponding to the first Huffman code word and parsing the decoding value to obtain the first bit length; S500, reading the bit data of the first bit length from the data buffer after the first Huffman code word as the quantization value data of the decoding value. For example, as shown in Figure 2c The current group of data to be decoded A1 is 1110 0011, and the next group of data to be decoded A2 is 1001 0010. Step S400 is executed to solve the first Huffman code word as 111000, find the corresponding decoding value as the hexadecimal value 06, calculate the run length as 0 according to the decoding value, and the bit width occupied by the non-zero coefficient is 6, wherein the bit width occupied by the non-zero coefficient is the first bit length. Step S500 is executed to read the bit data (111001) of the first bit length (6 bits) from the data buffer after the first Huffman code word (111000) as the non-zero quantization value data of the decoding value (hexadecimal value 06).

[0045] Please continue to refer to Figure 2c and Figure 3After the first group of data to be decoded completes the decoding steps described above, S600 is performed. If the sum of the first real code length (6) of the first Huffman code word and the first bit length (6) is not equal to an integer multiple of the set length (8), it is determined whether the next group of data to be decoded A3 (10010010) after the bit data of the first bit length in the data buffer is an ambiguous word. If it is not an ambiguous word, step S700 is performed. S700 reads a group of data to be decoded of the set length from the (M+N+1)th bit (the 13th bit from the first bit data of the current group (the first group)) of the current group of data to be decoded in the data buffer as cross-group data to be decoded (0010 1001), where M is the first real code length (6) and N is the first bit length (6). The cross-group data to be decoded is compared with one of the plurality of maximum extension code word values in sequence. If the cross-group data to be decoded is less than or equal to a certain maximum extension code word value, the comparison is stopped, the certain maximum extension code word value is taken as a second maximum extension code word value, a second real code length corresponding to the second maximum extension code word value is found in the mapping relationship, and bit data of the second real code length is read from the cross-group data to be decoded as a second Huffman code word. The method of solving the quantization value data of the second Huffman code word is the same as that of solving the quantization value data corresponding to the first Huffman code word, and will not be described again here.

[0046] As shown in Figure 2d , in step S600, if the next group of data to be decoded A3 is an ambiguous word such as 0xFF, step S800 is performed. S800 decodes the bit data (0010) between the bit data of the first bit length and the next group of data to be decoded A3 from the (M+N+1)th bit (the 13th bit from the first bit data of the current group (the first group)) of the current group of data to be decoded in sequence.

[0047] In some embodiments, the mapping relationship in step S200 includes a first sub-mapping relationship (as shown in Figure 4a ) and a second sub-mapping relationship (as shown in Figure 4b ). The first sub-mapping relationship is the relationship between the maximum extension code word value (denoted as p_cw[idx]) and the index (denoted as idx), and the second sub-mapping relationship is the relationship between the index idx and the real code length (for ease of understanding, the values of the real code length are listed in Figure 4a ). In practice, Figure 4athe first sub-mapping relationship does not exist (i.e., the real code length of the current group of to-be-decoded data A1 is equal to the real code length corresponding to the index idx=4). Specifically, S200 includes: step S210, searching for the index of the first maximum extended code word value corresponding to the current group of to-be-decoded data A1 in the first sub-mapping relationship. If the value of the current group of to-be-decoded data A1 is greater than p_cw[3] and less than or equal to p_cw[4], the real code length of the current group of to-be-decoded data A1 is equal to the real code length corresponding to the index idx=4, and step S220 is performed. S220, searching for the real code length of the current group of to-be-decoded data A1 in the second sub-mapping relationship according to the index. Specifically, according to the index idx=4, the real code length corresponding to idx=4 in the second sub-mapping relationship is searched to be 6, and the real code length in the to-be-decoded data is determined. In order to facilitate the subsequent further solving of the decoding value of the Huffman code word, in some embodiments, the second sub-mapping relationship is the relationship between the index value idx and the value of the real code length (denoted as p_len[idx]), as shown in the following table: Figure 4c

[0048] In some embodiments, searching for the decoding value corresponding to the first Huffman code word includes the following steps: S410, determining the first address according to the real code length, the first address being the address (denoted as hpos) of the minimum Huffman code word with the code length equal to the real code length in the Huffman coding table, wherein the Huffman coding table is used to store the decoding value corresponding to the Huffman code word. S420, calculating the difference between the first Huffman code word (denoted as tdat) and the minimum Huffman code word (denoted as hmin) as an address offset value. S430, determining the second address (denoted as code_pos, code_pos=hpos+(tdat-hmin)) based on the first address offset by the address offset value, and reading the value in the second address as the decoding value of the first Huffman code word.

[0049] If the real code length corresponding to the current group of to-be-decoded data is less than the set length, after the first Huffman code word is decoded, the last time the read bits are returned to the to-be-decoded data, and the to-be-decoded data that has not started decoding is continued to be decoded. In step S200, if the current group of to-be-decoded data A1 is greater than any maximum extended code word value stored in the first sub-mapping relationship, the Kth bit of the to-be-decoded data composed of the current group of to-be-decoded data and the next group of to-be-decoded data is decoded bit by bit, wherein K is equal to the set length plus 1.

[0050] ​If no Huffman code word in the preset length range is used when reading the Huffman code table, i.e. no Huffman code word with a real code length less than or equal to 8 exists, then each bit of each maximum extension code word value in the mapping relationship in the preset length range is assigned a value of 1 (if the preset length is 8, then each maximum extension code word value is FF, i.e. unsigned number 255), and the real code length in the second sub-mapping relationship is also assigned a value of 0 (correspondingly, each element of p len [idx] is assigned a value of -1). After reading the current group of data to be decoded from the data buffer, the current group of data to be decoded is compared with the plurality of maximum extension code word values in turn, if the current group of data to be decoded is less than or equal to any maximum extension code word value, the real code length corresponding to the index value of the maximum value is found in the second sub-mapping relationship, if the corresponding real code length is 0 (or the value p len [idx] corresponding to the real code length is -1), it is judged that the Huffman code word in the range of 1-8 is not present, and the decoding is started from the (9) bit after the preset length plus 1 bit by bit.

[0051] Since the memory space of the small embedded platform is limited, the data to be decoded is usually loaded into the data buffer in segments, so when the decoding of the data buffer is completed, the next segment of data to be decoded needs to be loaded. In order to indicate the timing of loading the next segment of data to be decoded, the embodiment further includes the following steps, please refer to Figure 2c, the remaining group number dptr is initialized as 4, and the remaining group number is used to record the number of groups of the remaining undecoded data to be decoded stored in the data buffer. The number of remaining undecoded bits of the current group of data to be decoded A1 is recorded as bitpos, and the initial value of bitpos is 8 if the set length is 8. After 1 bit of data is decoded, bitpos is decremented by 1. The tsign is set to indicate whether the number of remaining bits of the current group is greater than the real code length corresponding to the data to be decoded. Specifically, tsign = bitpos - real code length, and when tsign is greater than 0, it indicates that the number of remaining bits of the current group is greater than the real code length, and the value of bitpos is updated to tsign. When tsign is less than 0, it indicates that the number of remaining bits of the current group is less than the real code length, and the next group of data has started to be decoded, and the value of bitpos is updated to 8 + tsign. The first bit length is recorded as num. After reading the non-zero coefficient (quantized data) corresponding to the first Huffman code word, if there are still undecoded bits in the group of data to be decoded where the non-zero coefficient is located, the group of undecoded bit data is still counted in the remaining group number. Specifically, if the first real code length of the first Huffman code word is 6, after reading the first Huffman code word, the number of remaining undecoded bits of the current group of data to be decoded A1 is bitpos = 2. After the decoding value corresponding to the first Huffman code word is found according to the first Huffman code word, the first bit length num is parsed as 6. The first bit length num is greater than the number of remaining undecoded bits of the current group of data to be decoded bitpos = 2, and less than the sum of bitpos and the set length (8) (10), which indicates that the bit data stored in the A1 group has been completely decoded, and the group of undecoded bit data is A2-A4, and the remaining group number dptr = 3. If the first bit length num is 1, the first bit length num is less than the number of remaining undecoded bits of the current group of data to be decoded bitpos (bitpos = 2), which indicates that there are still undecoded bit data in the A1 group, and the group of undecoded bit data is A1-A4, and the remaining group number is 4. If the first bit length num is 14, the first bit length num is greater than the number of remaining undecoded bits of the current group of data to be decoded bitpos = 2, and greater than the sum of bitpos and the set length (10), which indicates that the bit data stored in the A1 and A2 groups has been completely decoded, and the group of undecoded bit data is A3-A4, and the remaining group number dptr = 2. In this way, when the remaining group number is 0, the next segment of data to be decoded is loaded into the data buffer.

[0052] Taking a specific AC component decoding process of a JPEG image as an example, in the first sub-mapping relationship, idx is an index, and p_cw is a maximum extended code word value, and in the second sub-mapping relationship, idx is an index, and p_len is a value corresponding to an actual code length (equal to the actual code length minus 1). The current group of to-be-decoded data is A1, which is 10100100, and is not an ambiguous word. S210 is executed, and it is determined that the value of A1 is less than the maximum extended code word value p_cw[3], and the index of the first maximum extended code word value corresponding to the current group of to-be-decoded data is idx=3. S220 is executed, and p_len[3]=3 is found in the second mapping relationship, and it is determined that the actual code length of the first Huffman code word in A1 is 4 (p_len[3]+1=4), and the first Huffman code word is 1010. S410 is executed, the minimum Huffman code word with the actual code length of 4 is 1010, the first address is recorded as hpos, S420 is executed, and the address offset value is calculated as 0. S430 is executed, and the second address is determined based on the first address and the address offset value. Because the address offset value is 0, the value of the second address in the embodiment is equal to the first address, and the decoding value (recorded as rvalue) corresponding to the first Huffman code word in the second address is 0x23, that is, the run length is 2 (corresponding to the decoding value of 2 bytes of zero quantization value data), and the first bit length is 3. The bit data (010) with the first bit length (3) is read from the first Huffman code word (1010) in the data buffer as the non-zero quantization value data of the decoding value.

[0053] After the quantization data is solved, inverse quantization and inverse DCT (Discrete Cosine Transform) operations are further performed. In the embodiment, when the Huffman coding is decoded, the decoding is performed in the MCU unit, the quantization value data is analyzed, and the inverse quantization and inverse DCT operations are still performed in the MCU unit until the final decoding value of all MCUs of a frame of image is solved. As shown in FIG. 6, after the quantization value of the i-th MCU is read, the inverse quantization and inverse DCT of the quantization data of the i-th MCU are performed until the decoding of all MCUs of a frame of image is completed (in the embodiment, a frame of image includes N MCUs). Figure 5

[0054] The application further provides a decoding device for a Huffman coded image, which comprises:

[0055] ​The buffer preparation module is configured to fill 1 to a set length on the right side of each maximum Huffman code word with a code length not greater than the set length to obtain a plurality of maximum expansion code word values, and establish a mapping relationship between each maximum expansion code word value and a corresponding real code length; buffer a plurality of groups of to-be-decoded data in a data buffer, wherein the length of each group of to-be-decoded data is the set length, and determine whether a current group of to-be-decoded data in the data buffer is an ambiguous word; if not, trigger the first decoding module to work, and if yes, trigger the second decoding module to work;

[0056] The first decoding module is configured to compare the current group of to-be-decoded data with one of the plurality of maximum expansion code word values in sequence, stop the comparison if the current group of to-be-decoded data is less than or equal to a certain maximum expansion code word value, take the certain maximum expansion code word value as a first maximum expansion code word value, find a first real code length corresponding to the first maximum expansion code word value in the mapping relationship, and read bit data with the first real code length from the current group of to-be-decoded data as a first Huffman code word.

[0057] The second decoding module is configured to decode in a manner different from that of the first decoding module according to a real meaning of the ambiguous word.

[0058] The application further provides an embedded display device which adopts the method for decoding a Huffman coded image as described above, or comprises the decoding apparatus as described above.

[0059] In addition, the application further provides a computer readable storage medium, such as a chip, an optical disc, etc., which stores a computer program and can implement the method as described above when executed.

[0060] It should be noted that the computer readable storage medium described in the embodiments of the present disclosure is not limited to the above-mentioned embodiments, for example, it can also be an electric, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples of the computer readable storage medium can include, but are not limited to, an electric connection with one or more conductive wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the embodiments of the present disclosure, the computer readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, device or apparatus.

[0061] Those skilled in the art can understand that the above-mentioned preferred embodiments can be freely combined and superimposed without conflict. Among them, the flowcharts and block diagrams in the drawings illustrate the possible implementation architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code containing one or more executable instructions for implementing the specified logic function. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in different orders than those noted in the drawings, for example, two blocks indicated in succession can actually be executed substantially in parallel, and sometimes they can be executed in reverse order, depending on the function involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of special-purpose hardware and computer instructions. The numbering of the steps herein is only for the convenience of description and reference, and does not limit the front and rear sequences, and the specific execution sequence is determined by the technology itself, and those skilled in the art can determine various allowed and reasonable sequences according to the technology itself.

[0062] It should be noted that the step numbering (letter or number) is used in the present application to refer to certain specific method steps, only for the purpose of convenience and brevity, and absolutely not to limit the order of the method steps by letters or numbers. Those skilled in the art can understand that the order of the related method steps should be determined by the technology itself, and should not be improperly limited by the existence of step numbering, and those skilled in the art can determine various allowed and reasonable step sequences according to the technology itself.

[0063] Those skilled in the art can understand that the above-mentioned preferred embodiments can be freely combined and superimposed without conflict.

[0064] It should be understood that the above-described embodiments are only exemplary and not limiting, and those skilled in the art can make various obvious or equivalent modifications or replacements to the above-described details without departing from the essential principles of the present application, which will be included in the scope of the claims of the present application.

Claims

1. A decoding method of a Huffman-coded image based on a maximum codeword, characterized by, The method comprises the following steps: S100, obtaining a plurality of maximum extended code word values by right filling 1 to a set length to each maximum Huffman code word with a code length not greater than the set length, and establishing a mapping relationship between each maximum extended code word value and a corresponding real code length; buffering a plurality of groups of to-be-decoded data in a data buffer, wherein the length of each group of to-be-decoded data is the set length, and determining whether a current group of to-be-decoded data in the data buffer is an ambiguous word, if not, executing S200, and if yes, executing S300; S200, comparing the current group of to-be-decoded data with one of the plurality of maximum extended code word values in sequence, if the current group of to-be-decoded data is less than or equal to a certain maximum extended code word value, stopping the comparison, taking the certain maximum extended code word value as a first maximum extended code word value, and finding a first real code length corresponding to the first maximum extended code word value in the mapping relationship, and reading bit data with the first real code length from the current group of to-be-decoded data as a first Huffman code word; S300, decoding according to a real meaning of the ambiguous word in a manner different from S200, comprising: determining whether a next group of to-be-decoded data is a hexadecimal value 00; if yes, determining that the real meaning of the ambiguous word is a component of the Huffman code word, and decoding bit by bit from the Kth bit of to-be-decoded data composed of the current group of to-be-decoded data and a next group of to-be-decoded data; wherein K is equal to the set length plus 1; if not, determining that the real meaning of the ambiguous word is a component of a marker code, and composing a marker code from the ambiguous word and the next group of to-be-decoded data, and decoding according to the real meaning of the marker code.

2. The decoding method of claim 1, wherein, The method further comprises the following steps after S200: S400, finding a decoding value corresponding to the first Huffman code word, and parsing the decoding value to obtain a first bit length; S500, reading bit data with the first bit length from the data buffer after the first Huffman code word as quantization value data of the decoding value.

3. The decoding method of claim 2, wherein, The method further comprises the following steps after S500: S600, if the sum of the real code length of the first Huffman code word and the first bit length is not equal to an integer multiple of the set length, determining whether a next group of to-be-decoded data after bit data with the first bit length in the data buffer is the ambiguous word, if not, executing step S700; S700, reading set length of to-be-decoded data from the first bit data of the current group of to-be-decoded data in the data buffer as a starting point to form cross-group to-be-decoded data; wherein M is the first real code length, and N is the first bit length; comparing the cross-group to-be-decoded data sequentially with one of the plurality of maximum extension codeword values, stopping the comparison if the cross-group to-be-decoded data is less than or equal to a certain maximum extension codeword value, taking the certain maximum extension codeword value as a second maximum extension codeword value, and searching for a second real code length corresponding to the second maximum extension codeword value in the mapping relationship, and reading bit data of the second real code length from the cross-group to-be-decoded data as a second Huffman codeword.

4. The decoding method of claim 3, wherein, in the S600, if the next-group to-be-decoded data is the ambiguous word, performing S800; S800, decoding bit data between the first bit length of bit data and the next-group to-be-decoded data, starting from the (M+N+1)th bit of the first bit data of the current-group to-be-decoded data.

5. The decoding method of claim 1, wherein, The mapping relationship includes a first sub-mapping relationship and a second sub-mapping relationship, the first sub-mapping relationship is a relationship between the maximum extension codeword value and an index, and the second sub-mapping relationship is a relationship between the index and the real code length. The searching for the first real code length corresponding to the first maximum extension codeword value in the mapping relationship includes: S210, searching for an index of the first maximum extension codeword value corresponding to the current-group to-be-decoded data in the first sub-mapping relationship; S220, searching for the first real code length corresponding to the current-group to-be-decoded data in the second sub-mapping relationship according to the index.

6. The decoding method of claim 2, wherein, In the S400, the decoding value corresponding to the first Huffman codeword is searched for by the following steps: S410, determining a first address according to the first real code length, the first address being an address of a minimum Huffman codeword with a code length equal to the first real code length in a Huffman coding table, the Huffman coding table being used to store decoding values corresponding to the Huffman codeword; S420, calculating a difference value between the first Huffman codeword and the minimum Huffman codeword as an address offset value; S430, determining a second address by offsetting the first address by the address offset value, and reading a value in the second address as the decoding value of the first Huffman codeword.

7. The decoding method of claim 5, wherein, in the S200, if the current-group to-be-decoded data is greater than any maximum extension codeword value, starting to decode from the Kth bit of to-be-decoded data composed of the current-group to-be-decoded data and the next-group to-be-decoded data, wherein K is equal to the set length plus 1.

8. A decoding apparatus for a maximum codeword-based Huffman coded image, characterized by comprising: a decoding table for decoding the maximum codeword-based Huffman coded image; and a decoding unit for decoding the maximum codeword-based Huffman coded image using the decoding table. including: The buffer preparation module is configured to fill all maximum Huffman code words with a code length not greater than a set length with 1 from the right side to the set length to obtain a plurality of maximum expansion code word values, and establish a mapping relationship between each maximum expansion code word value and a corresponding real code length; buffer a plurality of groups of to-be-decoded data in a data buffer, wherein the length of each group of to-be-decoded data is the set length, and determine whether a current group of to-be-decoded data in the data buffer is an ambiguous word; if not, trigger the first decoding module to work; if yes, trigger the second decoding module to work; The first decoding module is configured to compare the current group of to-be-decoded data with one of the plurality of maximum expansion code word values in sequence, stop the comparison if the current group of to-be-decoded data is less than or equal to a certain maximum expansion code word value, take the certain maximum expansion code word value as a first maximum expansion code word value, find a first real code length corresponding to the first maximum expansion code word value in the mapping relationship, and read bit data with the first real code length from the current group of to-be-decoded data as a first Huffman code word; The second decoding module is configured to decode in a manner different from the first decoding module according to the real meaning of the ambiguous word, and the second decoding module includes a numerical zero detection unit configured to determine whether a next group of to-be-decoded data is a hexadecimal numerical value 00; If yes, it is determined that the real meaning of the ambiguous word is a component of the Huffman code word, and the ambiguous word is decoded bit by bit from the Kth bit of to-be-decoded data composed of the current group of to-be-decoded data and a group of to-be-decoded data after the next group of to-be-decoded data; wherein K is equal to the set length plus 1; If not, it is determined that the real meaning of the ambiguous word is a component of a marker code, the ambiguous word and the next group of to-be-decoded data are combined to form a marker code, and the marker code is decoded according to the real meaning of the marker code.

9. The decoding apparatus of claim 8, wherein, The quantization value calculation module is configured to work after the first decoding module and is configured to: find a decoding value corresponding to the first Huffman code word, and parse the decoding value to obtain a first bit length; read bit data with the first bit length from the data buffer after the first Huffman code word as quantization value data of the decoding value.

10. An embedded display device, characterized by The method for decoding a Huffman coded image is performed by the method according to any one of claims 1-7, or the decoding device according to any one of claims 8-9.

11. A computer readable storage medium having stored thereon a computer program, characterized in that The computer program is executed by a processor to implement the method according to any one of claims 1-7.

12. A decoding chip, comprising: The computer program is executed by a processor to implement the method according to any one of claims 1-7. The computer program is executed by a processor to implement the method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Automatic generation of compact code tables

    CN101286744A

  • Huffman decoding method and device

    CN104980161A