mirror of
https://github.com/wader/fq.git
synced 2024-11-23 00:57:15 +03:00
icc_profile: Add element alignment bytes field
This commit is contained in:
parent
4b48828b32
commit
50d00d823d
@ -89,6 +89,8 @@ func iccProfileDecode(d *decode.D, in interface{}) interface{} {
|
||||
100..127 28 bytes reserved for future expansion - must be set to zeros
|
||||
*/
|
||||
|
||||
startByteOffset := d.Pos() / 8
|
||||
|
||||
// TODO: PokeU32()?
|
||||
size := d.U32()
|
||||
d.SeekRel(-4 * 8)
|
||||
@ -144,6 +146,15 @@ func iccProfileDecode(d *decode.D, in interface{}) interface{} {
|
||||
d.FieldBitBufLen("data", int64(size-4-4)*8)
|
||||
}
|
||||
})
|
||||
|
||||
// "All tag data is required to start on a 4-byte boundary (relative to the start of the profile data stream)"
|
||||
// we can't add this at the start of the element as we don't know how big the previous element in the stream
|
||||
// was. instead add alignment after if offset+size does not align and we're not at the last tag
|
||||
paddingBytes := ((int64(offset) - startByteOffset + int64(size)) % 4) % 4
|
||||
if i < tagCount-1 && paddingBytes != 0 {
|
||||
paddingStart := int64(offset) + int64(size)
|
||||
d.FieldBitBufRange("alignment", paddingStart*8, paddingBytes*8)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
12
format/icc/testdata/sRGB2014.fqtest
vendored
12
format/icc/testdata/sRGB2014.fqtest
vendored
@ -34,7 +34,7 @@ $ fq -d icc_profile verbose /sRGB2014.icc
|
||||
| | | tag_table: {} 0x80-0xbcf.7 (2896)
|
||||
0x080|00 00 00 10 |.... | count: 16 0x80-0x83.7 (4)
|
||||
| | | table: [16] 0x84-0xbcf.7 (2892)
|
||||
| | | [0]: element {} 0x84-0x1a6.7 (291)
|
||||
| | | [0]: element {} 0x84-0x1a9.7 (294)
|
||||
0x080| 64 65 73 63 | desc | signature: "desc" 0x84-0x87.7 (4)
|
||||
0x080| 00 00 01 44 | ...D | offset: 324 0x88-0x8b.7 (4)
|
||||
0x080| 00 00 00 63| ...c| size: 99 0x8c-0x8f.7 (4)
|
||||
@ -51,6 +51,7 @@ $ fq -d icc_profile verbose /sRGB2014.icc
|
||||
0x160| 00 00 00 00 00 00 00 00 00 00 00 00| ............| macintosh_description: "" 0x164-0x1a6.7 (67)
|
||||
0x170|00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................|
|
||||
* |until 0x1a6.7 (67) | |
|
||||
0x1a0| 00 58 59 | .XY | alignment: 005859 0x1a7-0x1a9.7 (3)
|
||||
| | | [1]: element {} 0x90-0x1bb.7 (300)
|
||||
0x090|62 58 59 5a |bXYZ | signature: "bXYZ" 0x90-0x93.7 (4)
|
||||
0x090| 00 00 01 a8 | .... | offset: 424 0x94-0x97.7 (4)
|
||||
@ -156,7 +157,7 @@ $ fq -d icc_profile verbose /sRGB2014.icc
|
||||
0xac0| 73 69 67 20 | sig | type: "sig " 0xac4-0xac7.7 (4)
|
||||
0xac0| 00 00 00 00 | .... | reserved: 0 0xac8-0xacb.7 (4)
|
||||
0xac0| 43 52 54 20| CRT | data: 43525420 0xacc-0xacf.7 (4)
|
||||
| | | [12]: element {} 0x114-0xb56.7 (2627)
|
||||
| | | [12]: element {} 0x114-0xb59.7 (2630)
|
||||
0x110| 76 75 65 64 | vued | signature: "vued" 0x114-0x117.7 (4)
|
||||
0x110| 00 00 0a d0 | .... | offset: 2768 0x118-0x11b.7 (4)
|
||||
0x110| 00 00 00 87| ....| size: 135 0x11c-0x11f.7 (4)
|
||||
@ -175,6 +176,7 @@ $ fq -d icc_profile verbose /sRGB2014.icc
|
||||
0xb10| 00 00 00 00 00 00 00 00 00 00 00 00| ............| macintosh_description: "" 0xb14-0xb56.7 (67)
|
||||
0xb20|00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................|
|
||||
* |until 0xb56.7 (67) | |
|
||||
0xb50| 00 58 59 | .XY | alignment: 005859 0xb57-0xb59.7 (3)
|
||||
| | | [13]: element {} 0x120-0xb6b.7 (2636)
|
||||
0x120|77 74 70 74 |wtpt | signature: "wtpt" 0x120-0x123.7 (4)
|
||||
0x120| 00 00 0b 58 | ...X | offset: 2904 0x124-0x127.7 (4)
|
||||
@ -184,7 +186,7 @@ $ fq -d icc_profile verbose /sRGB2014.icc
|
||||
0xb60|00 00 f6 d6 |.... | X: 0.964202880859375 0xb60-0xb63.7 (4)
|
||||
0xb60| 00 01 00 00 | .... | Y: 1 0xb64-0xb67.7 (4)
|
||||
0xb60| 00 00 d3 2d | ...- | Z: 0.8249053955078125 0xb68-0xb6b.7 (4)
|
||||
| | | [14]: element {} 0x12c-0xba2.7 (2679)
|
||||
| | | [14]: element {} 0x12c-0xba5.7 (2682)
|
||||
0x120| 63 70 72 74| cprt| signature: "cprt" 0x12c-0x12f.7 (4)
|
||||
0x130|00 00 0b 6c |...l | offset: 2924 0x130-0x133.7 (4)
|
||||
0x130| 00 00 00 37 | ...7 | size: 55 0x134-0x137.7 (4)
|
||||
@ -193,6 +195,7 @@ $ fq -d icc_profile verbose /sRGB2014.icc
|
||||
0xb70| 43 6f 70 79 72 69 67 68 74 20 49 6e| Copyright In| text: "Copyright International Color Consortium, 2015" 0xb74-0xba2.7 (47)
|
||||
0xb80|74 65 72 6e 61 74 69 6f 6e 61 6c 20 43 6f 6c 6f|ternational Colo|
|
||||
* |until 0xba2.7 (47) | |
|
||||
0xba0| 00 73 66 | .sf | alignment: 007366 0xba3-0xba5.7 (3)
|
||||
| | | [15]: element {} 0x138-0xbcf.7 (2712)
|
||||
0x130| 63 68 61 64 | chad | signature: "chad" 0x138-0x13b.7 (4)
|
||||
0x130| 00 00 0b a4| ....| offset: 2980 0x13c-0x13f.7 (4)
|
||||
@ -202,6 +205,3 @@ $ fq -d icc_profile verbose /sRGB2014.icc
|
||||
0xba0| 00 01 0c 44| ...D| data: 00010c44000005dffffff32600000794... 0xbac-0xbcf.7 (36)
|
||||
0xbb0|00 00 05 df ff ff f3 26 00 00 07 94 00 00 fd 8f|.......&........|
|
||||
0xbc0|ff ff fb a1 ff ff fd a2 00 00 03 db 00 00 c0 75|...............u|
|
||||
0x1a0| 00 | . | unknown0: 00 0x1a7-0x1a7.7 (1)
|
||||
0xb50| 00 | . | unknown1: 00 0xb57-0xb57.7 (1)
|
||||
0xba0| 00 | . | unknown2: 00 0xba3-0xba3.7 (1)
|
||||
|
Loading…
Reference in New Issue
Block a user