-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspecification.txt
129 lines (106 loc) · 3.45 KB
/
specification.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
RGB image compression.
MAIN_IMAGE
consists of:
- VARINT width minus 1
- VARINT height minus 1
- IMAGE
its RANGE is 256
IMAGE:
An IMAGE consists of:
- METHOD
- TRANSFORM_DATA
- IMAGE_DATA
To decode an IMAGE, its width, height and RANGE are also required.
METHOD:
- BYTE
where the bits have the following meanings (most significant bit first)
- bit 0:
RESERVED, may be used for PROGRESSIVE in the future
- bit 1:
0 means greyscale, only one channel is coded, with the other two equal to the first.
1 means colour
- bit 2:
SUBTRACT_GREEN transform is used
- bit 3:
INDEX_TRANSFORM is used
- bit 4:
COLOUR_TRANSFORM is used
- bit 5:
PREDICTION_TRANSFORM is used
- bit 6:
ENTROPY_CODING is used
- bit 7:
LZ is used
not all combindations are valid:
- bit 0 should not be set
- if bit 1 unset{
- bit 4 should not be set
}
- if bit 2 set{
- bit 3 should not be set
- bit 4 should not be set
}
- if bit 3 set{
- bit 4 should not be set
}
- if bit 4 set{
- bit 3 should not be set
}
- if bit 6 unset{
- bit 4 should not be set
- bit 5 should not be set
- bit 7 should not be set
}
if bit 2 is not set on the main image, it should not be set on any of the sub images
bit 2 should not be set on an INDEX_INDEX_IMAGE
VARINT:
encodes a 28bit number.
the most significant bit is not counted, and if it is set indicates that another byte should be read.
the first byte contains the 7 least significant digits of the 28bit number, the second the next seven, and so on.
a varint may not have more than 4 bytes, and the most significant bit of the last byte should not be set.
TRANSFORM_DATA:
contains the following data in order, if their respective METHOD bits are set
- (conditional) INDEX_TRANSFORM_DATA
- (conditional) COLOUR_TRANSFORM_DATA
- (conditional) PREDICTION_TRANSFORM_DATA
- (conditional) ENTROPY_CODING_DATA
- (conditional) LZ_DATA
INDEX_TRANSFORM_DATA:
- BYTE: indicating the width of the INDEX_IMAGE minus 1
- BYTE: indicating the height of the INDEX_IMAGE minus 1
- INDEX_IMAGE
- (conditional) VARINT: index_index_image width minus 1
- (conditional) VARINT: index_index_image height minus 1
- (conditional) INDEX_INDEX_IMAGE
INDEX_IMAGE:
- IMAGE
each row represent an INDEX.
if a pixel is repeated in an INDEX, the INDEX is terminated, and the repeated pixel and the remaining pixels of the row are coded, but have no meaning for the INDEX.
INDEX:
a list of pixel values, at most 256 entries long.
INDEX_INDEX_IMAGE:
if the height of the INDEX_IMAGE is greater than 1, a second image divides the parent IMAGE into blocks to indicate which INDEX is used where
COLOUR_TRANSFORM_DATA:
- VARINT: COLOUR_TRANSFORM_IMAGE width minus 1
- VARINT: COLOUR_TRANSFORM_IMAGE height minus 1
- COLOUR_TRANSFORM_IMAGE
COLOUR_TRANSFORM_IMAGE:
- IMAGE
where each pixel has the GREEN_TO_RED, GREEN_TO_BLUE and RED_TO_BLUE transform values in a RANGE of 256 to be used for eah block
PREDICTION_TRANSFORM_DATA:
- BYTE: number of predictors to use minus 1
- (1-256) PREDICTOR
- (conditional) VARINT: predictor_image width minus 1
- (conditional) VARINT: predictor_image height minus 1
- (conditional) PREDICTOR_IMAGE
PREDICTOR:
- BYTE: a, b
- BYTE: c, d
ENTROPY_CODING_DATA:
- BYTE: number of entropy tables minus 1
- ENTROPY_TABLE_LIST
- (conditional) VARINT: entropy_image width minus 1
- (conditional) VARINT: entropy_image height minus 1
- (conditional) ENTROPY_IMAGE
LZ_DATA
- LZ_TABLE_LIST