png_codec/
consts.rs

1// Magic bytes to start a PNG file.
2pub(super) const PNG_SIGNATURE: [u8; 8] = [137, 80, 78, 71, 13, 10, 26, 10];
3
4// Chunk Identifiers
5pub(super) const IMAGE_HEADER: [u8; 4] = *b"IHDR";
6pub(super) const IMAGE_DATA: [u8; 4] = *b"IDAT";
7pub(super) const TRANSPARENCY: [u8; 4] = *b"tRNS";
8pub(super) const IMAGE_END: [u8; 4] = *b"IEND";
9pub(super) const PALETTE: [u8; 4] = *b"PLTE";
10// pub(super) const ITEXT: [u8; 4] = *b"iTXt";
11// pub(super) const PHYSICAL: [u8; 4] = *b"pHYs";
12// pub(super) const TIME: [u8; 4] = *b"tIME";
13// pub(super) const ZTEXT: [u8; 4] = *b"zTXt";
14// pub(super) const TEXT: [u8; 4] = *b"tEXt";
15
16pub(super) const MAX_CHUNK_SIZE: usize = 1 << 31; // 2³¹
17
18// Initial value for CRC32 Checksum
19pub(super) const CRC32_INIT: u32 = 4_294_967_295;
20// Look-up table for CRC32 Checksum
21pub(super) const CRC32_LOOKUP: [u32; 256] = [
22    0,
23    1_996_959_894,
24    3_993_919_788,
25    2_567_524_794,
26    124_634_137,
27    1_886_057_615,
28    3_915_621_685,
29    2_657_392_035,
30    249_268_274,
31    2_044_508_324,
32    3_772_115_230,
33    2_547_177_864,
34    162_941_995,
35    2_125_561_021,
36    3_887_607_047,
37    2_428_444_049,
38    498_536_548,
39    1_789_927_666,
40    4_089_016_648,
41    2_227_061_214,
42    450_548_861,
43    1_843_258_603,
44    4_107_580_753,
45    2_211_677_639,
46    325_883_990,
47    1_684_777_152,
48    4_251_122_042,
49    2_321_926_636,
50    335_633_487,
51    1_661_365_465,
52    4_195_302_755,
53    2_366_115_317,
54    997_073_096,
55    1_281_953_886,
56    3_579_855_332,
57    2_724_688_242,
58    1_006_888_145,
59    1_258_607_687,
60    3_524_101_629,
61    2_768_942_443,
62    901_097_722,
63    1_119_000_684,
64    3_686_517_206,
65    2_898_065_728,
66    853_044_451,
67    1_172_266_101,
68    3_705_015_759,
69    2_882_616_665,
70    651_767_980,
71    1_373_503_546,
72    3_369_554_304,
73    3_218_104_598,
74    565_507_253,
75    1_454_621_731,
76    3_485_111_705,
77    3_099_436_303,
78    671_266_974,
79    1_594_198_024,
80    3_322_730_930,
81    2_970_347_812,
82    795_835_527,
83    1_483_230_225,
84    3_244_367_275,
85    3_060_149_565,
86    1_994_146_192,
87    31_158_534,
88    2_563_907_772,
89    4_023_717_930,
90    1_907_459_465,
91    112_637_215,
92    2_680_153_253,
93    3_904_427_059,
94    2_013_776_290,
95    251_722_036,
96    2_517_215_374,
97    3_775_830_040,
98    2_137_656_763,
99    141_376_813,
100    2_439_277_719,
101    3_865_271_297,
102    1_802_195_444,
103    476_864_866,
104    2_238_001_368,
105    4_066_508_878,
106    1_812_370_925,
107    453_092_731,
108    2_181_625_025,
109    4_111_451_223,
110    1_706_088_902,
111    314_042_704,
112    2_344_532_202,
113    4_240_017_532,
114    1_658_658_271,
115    366_619_977,
116    2_362_670_323,
117    4_224_994_405,
118    1_303_535_960,
119    984_961_486,
120    2_747_007_092,
121    3_569_037_538,
122    1_256_170_817,
123    1_037_604_311,
124    2_765_210_733,
125    3_554_079_995,
126    1_131_014_506,
127    879_679_996,
128    2_909_243_462,
129    3_663_771_856,
130    1_141_124_467,
131    855_842_277,
132    2_852_801_631,
133    3_708_648_649,
134    1_342_533_948,
135    654_459_306,
136    3_188_396_048,
137    3_373_015_174,
138    1_466_479_909,
139    544_179_635,
140    3_110_523_913,
141    3_462_522_015,
142    1_591_671_054,
143    702_138_776,
144    2_966_460_450,
145    3_352_799_412,
146    1_504_918_807,
147    783_551_873,
148    3_082_640_443,
149    3_233_442_989,
150    3_988_292_384,
151    2_596_254_646,
152    62_317_068,
153    1_957_810_842,
154    3_939_845_945,
155    2_647_816_111,
156    81_470_997,
157    1_943_803_523,
158    3_814_918_930,
159    2_489_596_804,
160    225_274_430,
161    2_053_790_376,
162    3_826_175_755,
163    2_466_906_013,
164    167_816_743,
165    2_097_651_377,
166    4_027_552_580,
167    2_265_490_386,
168    503_444_072,
169    1_762_050_814,
170    4_150_417_245,
171    2_154_129_355,
172    426_522_225,
173    1_852_507_879,
174    4_275_313_526,
175    2_312_317_920,
176    282_753_626,
177    1_742_555_852,
178    4_189_708_143,
179    2_394_877_945,
180    397_917_763,
181    1_622_183_637,
182    3_604_390_888,
183    2_714_866_558,
184    953_729_732,
185    1_340_076_626,
186    3_518_719_985,
187    2_797_360_999,
188    1_068_828_381,
189    1_219_638_859,
190    3_624_741_850,
191    2_936_675_148,
192    906_185_462,
193    1_090_812_512,
194    3_747_672_003,
195    2_825_379_669,
196    829_329_135,
197    1_181_335_161,
198    3_412_177_804,
199    3_160_834_842,
200    628_085_408,
201    1_382_605_366,
202    3_423_369_109,
203    3_138_078_467,
204    570_562_233,
205    1_426_400_815,
206    3_317_316_542,
207    2_998_733_608,
208    733_239_954,
209    1_555_261_956,
210    3_268_935_591,
211    3_050_360_625,
212    752_459_403,
213    1_541_320_221,
214    2_607_071_920,
215    3_965_973_030,
216    1_969_922_972,
217    40_735_498,
218    2_617_837_225,
219    3_943_577_151,
220    1_913_087_877,
221    83_908_371,
222    2_512_341_634,
223    3_803_740_692,
224    2_075_208_622,
225    213_261_112,
226    2_463_272_603,
227    3_855_990_285,
228    2_094_854_071,
229    198_958_881,
230    2_262_029_012,
231    4_057_260_610,
232    1_759_359_992,
233    534_414_190,
234    2_176_718_541,
235    4_139_329_115,
236    1_873_836_001,
237    414_664_567,
238    2_282_248_934,
239    4_279_200_368,
240    1_711_684_554,
241    285_281_116,
242    2_405_801_727,
243    4_167_216_745,
244    1_634_467_795,
245    376_229_701,
246    2_685_067_896,
247    3_608_007_406,
248    1_308_918_612,
249    956_543_938,
250    2_808_555_105,
251    3_495_958_263,
252    1_231_636_301,
253    1_047_427_035,
254    2_932_959_818,
255    3_654_703_836,
256    1_088_359_270,
257    936_918_000,
258    2_847_714_899,
259    3_736_837_829,
260    1_202_900_863,
261    817_233_897,
262    3_183_342_108,
263    3_401_237_130,
264    1_404_277_552,
265    615_818_150,
266    3_134_207_493,
267    3_453_421_203,
268    1_423_857_449,
269    601_450_431,
270    3_009_837_614,
271    3_294_710_456,
272    1_567_103_746,
273    711_928_724,
274    3_020_668_471,
275    3_272_380_065,
276    1_510_334_235,
277    755_167_117,
278];