【问题标题】:Understanding IDAT, reading DEFLATE's dynamic Huffman tree理解 IDAT,阅读 DEFLATE 的动态霍夫曼树
【发布时间】:2019-04-06 01:57:20
【问题描述】:

我希望更好地理解 zlib、deflate 和 PNG 编码。话虽如此,我无法将 RFC-1950 和 RFC-1951 的规范应用于 PNG 的 IDAT 部分。

下面是图像的二进制。

示例图像为 50x50,所有像素均为 RGB(255,0,0)。

好的,在 IDAT 之后,期望 zlib 指定的两个字节; CMF [0000029] 然后是 FLG [000002a](没有 FLG.FDICT)。正如预期的那样,十六进制是78DA,这意味着使用 DEFLATE、32K 窗口和高级别压缩。

从下一个字节的最低有效位开始,将有三个用于 DEFLATE 标头,一个位指定最后一个块,两个位用于压缩类型(无、固定、或动态)[000002b]

要读取位,请参阅this

0000024: 01000011 01001001 01000100 01000001 01010100 01111000  CIDATx
000002a: 11011010 11101101 11001111 00110001 00010001 00000000  ...1..
0000030: 00000000 00001000 00000000 10100001 11101111 01011111  ....._
0000036: 01011010 00110011 10111000 01111010 00001100 00000100  Z3.z..
000003c: 10100000 10101001 11111001 00100000 00010001 00010001  ... ..
0000042: 00010001 00010001 00010001 00010001 00010001 00010001  ......
0000048: 00010001 00010001 00010001 00010001 00010001 00010001  ......
000004e: 00010001 00010001 00010001 00010001 00010001 00010001  ......
0000054: 00010001 00010001 00010001 00010001 00010001 00010001  ......
000005a: 00010001 00010001 00010001 00010001 00010001 00010001  ......
0000060: 00010001 00010001 00010001 00010001 00010001 10010001  ......
0000066: 10001011 00000101 10110000 00110011 01110101 10010110  ...3u.
000006c: 01111001 11000101 00011100 10110001 00000000 00000000  y.....
0000072: 00000000 00000000 01001001 01000101 01001110 01000100  ..

【问题讨论】:

    标签: png zlib huffman-code deflate


    【解决方案1】:

    接下来的三位来自11101101 的底部。 101 是动态块的101 表示这是最后一个块。这会启动一个 61 字节的 deflate 流,它会解码为以下内容(由 infgen 反汇编):

    last
    dynamic
    litlen 0 2
    litlen 255 4
    litlen 256 4
    litlen 274 4
    litlen 283 4
    litlen 285 1
    dist 3 1
    dist 15 1
    literal 0 255 0 0 255
    match 196 4
    literal 0
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 258 201
    match 44 4
    end
    

    第一个解压字节为零,解压为 10,050 字节。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-15
      • 2014-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-28
      • 1970-01-01
      相关资源
      最近更新 更多