mirror of
https://github.com/wader/fq.git
synced 2024-08-17 16:00:41 +03:00
Merge pull request #934 from matmat/dht-patch
jpeg: Add parsing of DHT parameters
This commit is contained in:
commit
b8eec4078f
@ -262,6 +262,29 @@ func jpegDecode(d *decode.D) any {
|
||||
}
|
||||
})
|
||||
})
|
||||
case DHT:
|
||||
lH := int64(d.FieldU16("lh"))
|
||||
d.FramedFn(lH*8-16, func(d *decode.D) {
|
||||
d.FieldArray("hs", func(d *decode.D) {
|
||||
for d.NotEnd() {
|
||||
d.FieldStruct("h", func(d *decode.D) {
|
||||
d.FieldU4("tc")
|
||||
d.FieldU4("th")
|
||||
hK := uint64(0)
|
||||
hV := uint64(0)
|
||||
d.FieldArrayLoop("l", func() bool { return hK < 16 }, func(d *decode.D) {
|
||||
hV += d.FieldU8("l")
|
||||
hK++
|
||||
})
|
||||
hK = 0
|
||||
d.FieldArrayLoop("v", func() bool { return hK < hV }, func(d *decode.D) {
|
||||
d.FieldU8("v")
|
||||
hK++
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
case RST0, RST1, RST2, RST3, RST4, RST5, RST6, RST7:
|
||||
inECD = true
|
||||
case TEM:
|
||||
|
54
format/jpeg/testdata/4x4.fqtest
vendored
54
format/jpeg/testdata/4x4.fqtest
vendored
@ -109,15 +109,57 @@ $ fq -d jpeg dv 4x4.jpg
|
||||
| | | [4]{}: marker 0x66-0x7c (22)
|
||||
0x60| ff | . | prefix: raw bits (valid) 0x66-0x67 (1)
|
||||
0x60| c4 | . | code: "dht" (196) (Define Huffman table(s)) 0x67-0x68 (1)
|
||||
0x60| 00 14 | .. | length: 20 0x68-0x6a (2)
|
||||
0x60| 00 01 00 00 00 00| ......| data: raw bits 0x6a-0x7c (18)
|
||||
0x70|00 00 00 00 00 00 00 00 00 00 00 08 |............ |
|
||||
0x60| 00 14 | .. | lh: 20 0x68-0x6a (2)
|
||||
| | | hs[0:1]: 0x6a-0x7c (18)
|
||||
| | | [0]{}: h 0x6a-0x7c (18)
|
||||
0x60| 00 | . | tc: 0 0x6a-0x6a.4 (0.4)
|
||||
0x60| 00 | . | th: 0 0x6a.4-0x6b (0.4)
|
||||
| | | l[0:16]: 0x6b-0x7b (16)
|
||||
0x60| 01 | . | [0]: 1 l 0x6b-0x6c (1)
|
||||
0x60| 00 | . | [1]: 0 l 0x6c-0x6d (1)
|
||||
0x60| 00 | . | [2]: 0 l 0x6d-0x6e (1)
|
||||
0x60| 00 | . | [3]: 0 l 0x6e-0x6f (1)
|
||||
0x60| 00| .| [4]: 0 l 0x6f-0x70 (1)
|
||||
0x70|00 |. | [5]: 0 l 0x70-0x71 (1)
|
||||
0x70| 00 | . | [6]: 0 l 0x71-0x72 (1)
|
||||
0x70| 00 | . | [7]: 0 l 0x72-0x73 (1)
|
||||
0x70| 00 | . | [8]: 0 l 0x73-0x74 (1)
|
||||
0x70| 00 | . | [9]: 0 l 0x74-0x75 (1)
|
||||
0x70| 00 | . | [10]: 0 l 0x75-0x76 (1)
|
||||
0x70| 00 | . | [11]: 0 l 0x76-0x77 (1)
|
||||
0x70| 00 | . | [12]: 0 l 0x77-0x78 (1)
|
||||
0x70| 00 | . | [13]: 0 l 0x78-0x79 (1)
|
||||
0x70| 00 | . | [14]: 0 l 0x79-0x7a (1)
|
||||
0x70| 00 | . | [15]: 0 l 0x7a-0x7b (1)
|
||||
| | | v[0:1]: 0x7b-0x7c (1)
|
||||
0x70| 08 | . | [0]: 8 v 0x7b-0x7c (1)
|
||||
| | | [5]{}: marker 0x7c-0x92 (22)
|
||||
0x70| ff | . | prefix: raw bits (valid) 0x7c-0x7d (1)
|
||||
0x70| c4 | . | code: "dht" (196) (Define Huffman table(s)) 0x7d-0x7e (1)
|
||||
0x70| 00 14| ..| length: 20 0x7e-0x80 (2)
|
||||
0x80|10 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................| data: raw bits 0x80-0x92 (18)
|
||||
0x90|00 00 |.. |
|
||||
0x70| 00 14| ..| lh: 20 0x7e-0x80 (2)
|
||||
| | | hs[0:1]: 0x80-0x92 (18)
|
||||
| | | [0]{}: h 0x80-0x92 (18)
|
||||
0x80|10 |. | tc: 1 0x80-0x80.4 (0.4)
|
||||
0x80|10 |. | th: 0 0x80.4-0x81 (0.4)
|
||||
| | | l[0:16]: 0x81-0x91 (16)
|
||||
0x80| 01 | . | [0]: 1 l 0x81-0x82 (1)
|
||||
0x80| 00 | . | [1]: 0 l 0x82-0x83 (1)
|
||||
0x80| 00 | . | [2]: 0 l 0x83-0x84 (1)
|
||||
0x80| 00 | . | [3]: 0 l 0x84-0x85 (1)
|
||||
0x80| 00 | . | [4]: 0 l 0x85-0x86 (1)
|
||||
0x80| 00 | . | [5]: 0 l 0x86-0x87 (1)
|
||||
0x80| 00 | . | [6]: 0 l 0x87-0x88 (1)
|
||||
0x80| 00 | . | [7]: 0 l 0x88-0x89 (1)
|
||||
0x80| 00 | . | [8]: 0 l 0x89-0x8a (1)
|
||||
0x80| 00 | . | [9]: 0 l 0x8a-0x8b (1)
|
||||
0x80| 00 | . | [10]: 0 l 0x8b-0x8c (1)
|
||||
0x80| 00 | . | [11]: 0 l 0x8c-0x8d (1)
|
||||
0x80| 00 | . | [12]: 0 l 0x8d-0x8e (1)
|
||||
0x80| 00 | . | [13]: 0 l 0x8e-0x8f (1)
|
||||
0x80| 00| .| [14]: 0 l 0x8f-0x90 (1)
|
||||
0x90|00 |. | [15]: 0 l 0x90-0x91 (1)
|
||||
| | | v[0:1]: 0x91-0x92 (1)
|
||||
0x90| 00 | . | [0]: 0 v 0x91-0x92 (1)
|
||||
| | | [6]{}: marker 0x92-0x9c (10)
|
||||
0x90| ff | . | prefix: raw bits (valid) 0x92-0x93 (1)
|
||||
0x90| da | . | code: "sos" (218) (Start of scan) 0x93-0x94 (1)
|
||||
|
Loading…
Reference in New Issue
Block a user