解码JPEG霍夫曼块(表)

时间:2022-10-02 19:11:16

The following block is nested by Huffman block markers

以下块由Huffman块标记嵌套

-HUFF---------------------------------------------------------------------0084-
  10    0    1    2    4    3    4    6    5    6    8    a    9    4    2    3
   0    1    2   11    0    3    4   21    5   12   31    6   41   51   61   13
  22   71   81   91   a1   14   32   b1   d1   f0   15   23   35   42   b2   c1
   7   16   24   33   52   72   73   e1   25   34   43   53   62   74   82   94
  a2   f1   26   44   54   63   64   92   93   c2   d2   55   56   84   b3   45
  83   46   a3   e2
-------------------------------------------------------------------------------

0084 is the length of the table as an integer and is not included in the block here

0084是整数表的长度,不包括在这里的块中

according to the JPEG standard, the first address aparently makes it an AC table at destination 0 (0x10)

根据JPEG标准,第一个地址显然使它成为目的地0(0x10)的AC表

and aparently from there onwards it's a huffman table.

而且从那里开始它就是一张霍夫曼桌子。

So, how is it decoded?

那么,它是如何解码的?

1 个解决方案

#1


21  

The next 16 bytes after the 0x10 tell you how many codes of each length. In your example, there are 0 codes of length 1 bit, 1 code of length 2 bits, 2 codes of length 3 bits, 4 codes of length 4 bits, 3 codes of length 5 bits, and so on.

0x10之后的下一个16字节告诉您每个长度的代码数量。在您的示例中,有0个长度为1位的代码,1个长度为2位的代码,2个长度为3位的代码,4个长度为4位的代码,3个长度为5位的代码,依此类推。

These are then followed by the values that are encoded by those codes, in order. Again from your example:

然后按顺序跟随这些代码编码的值。再次从你的例子:

Code length | Number | Symbol(s)
------------+--------+----------
1 bit       | 0      |
2 bits      | 1      | 0x01
3 bits      | 2      | 0x02 0x11
4 bits      | 4      | 0x00 0x03 0x04 0x21
5 bits      | 3      | 0x05 0x12 0x31
... etc

You then build a binary tree from the top down, assigning the symbols in order. In this example, you get:

然后,您从上到下构建二叉树,按顺序分配符号。在这个例子中,你得到:

Symbol | Code 
-------+------
0x01   | 00
0x02   | 010
0x11   | 011
0x00   | 1000
0x03   | 1001
0x04   | 1010
0x21   | 1011
...etc

#1


21  

The next 16 bytes after the 0x10 tell you how many codes of each length. In your example, there are 0 codes of length 1 bit, 1 code of length 2 bits, 2 codes of length 3 bits, 4 codes of length 4 bits, 3 codes of length 5 bits, and so on.

0x10之后的下一个16字节告诉您每个长度的代码数量。在您的示例中,有0个长度为1位的代码,1个长度为2位的代码,2个长度为3位的代码,4个长度为4位的代码,3个长度为5位的代码,依此类推。

These are then followed by the values that are encoded by those codes, in order. Again from your example:

然后按顺序跟随这些代码编码的值。再次从你的例子:

Code length | Number | Symbol(s)
------------+--------+----------
1 bit       | 0      |
2 bits      | 1      | 0x01
3 bits      | 2      | 0x02 0x11
4 bits      | 4      | 0x00 0x03 0x04 0x21
5 bits      | 3      | 0x05 0x12 0x31
... etc

You then build a binary tree from the top down, assigning the symbols in order. In this example, you get:

然后,您从上到下构建二叉树,按顺序分配符号。在这个例子中,你得到:

Symbol | Code 
-------+------
0x01   | 00
0x02   | 010
0x11   | 011
0x00   | 1000
0x03   | 1001
0x04   | 1010
0x21   | 1011
...etc