table.go 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972
  1. // generated by "go run gen.go". DO NOT EDIT.
  2. package ccitt
  3. // Each decodeTable is represented by an array of [2]int16's: a binary tree.
  4. // Each array element (other than element 0, which means invalid) is a branch
  5. // node in that tree. The root node is always element 1 (the second element).
  6. //
  7. // To walk the tree, look at the next bit in the bit stream, using it to select
  8. // the first or second element of the [2]int16. If that int16 is 0, we have an
  9. // invalid code. If it is positive, go to that branch node. If it is negative,
  10. // then we have a leaf node, whose value is the bitwise complement (the ^
  11. // operator) of that int16.
  12. //
  13. // Comments above each decodeTable also show the same structure visually. The
  14. // "b123" lines show the 123'rd branch node. The "=XXXXX" lines show an invalid
  15. // code. The "=v1234" lines show a leaf node with value 1234. When reading the
  16. // bit stream, a 0 or 1 bit means to go up or down, as you move left to right.
  17. //
  18. // For example, in modeDecodeTable, branch node b005 is three steps up from the
  19. // root node, meaning that we have already seen "000". If the next bit is "0"
  20. // then we move to branch node b006. Otherwise, the next bit is "1", and we
  21. // move to the leaf node v0000 (also known as the modePass constant). Indeed,
  22. // the bits that encode modePass are "0001".
  23. //
  24. // Tables 1, 2 and 3 come from the "ITU-T Recommendation T.6: FACSIMILE CODING
  25. // SCHEMES AND CODING CONTROL FUNCTIONS FOR GROUP 4 FACSIMILE APPARATUS"
  26. // specification:
  27. //
  28. // https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-T.6-198811-I!!PDF-E&type=items
  29. // modeDecodeTable represents Table 1 and the End-of-Line code.
  30. //
  31. // +=XXXXX
  32. // b009 +-+
  33. // | +=v0009
  34. // b007 +-+
  35. // | | +=v0008
  36. // b010 | +-+
  37. // | +=v0005
  38. // b006 +-+
  39. // | | +=v0007
  40. // b008 | +-+
  41. // | +=v0004
  42. // b005 +-+
  43. // | +=v0000
  44. // b003 +-+
  45. // | +=v0001
  46. // b002 +-+
  47. // | | +=v0006
  48. // b004 | +-+
  49. // | +=v0003
  50. // b001 +-+
  51. // +=v0002
  52. var modeDecodeTable = [...][2]int16{
  53. 0: {0, 0},
  54. 1: {2, ^2},
  55. 2: {3, 4},
  56. 3: {5, ^1},
  57. 4: {^6, ^3},
  58. 5: {6, ^0},
  59. 6: {7, 8},
  60. 7: {9, 10},
  61. 8: {^7, ^4},
  62. 9: {0, ^9},
  63. 10: {^8, ^5},
  64. }
  65. // whiteDecodeTable represents Tables 2 and 3 for a white run.
  66. //
  67. // +=XXXXX
  68. // b059 +-+
  69. // | | +=v1792
  70. // b096 | | +-+
  71. // | | | | +=v1984
  72. // b100 | | | +-+
  73. // | | | +=v2048
  74. // b094 | | +-+
  75. // | | | | +=v2112
  76. // b101 | | | | +-+
  77. // | | | | | +=v2176
  78. // b097 | | | +-+
  79. // | | | | +=v2240
  80. // b102 | | | +-+
  81. // | | | +=v2304
  82. // b085 | +-+
  83. // | | +=v1856
  84. // b098 | | +-+
  85. // | | | +=v1920
  86. // b095 | +-+
  87. // | | +=v2368
  88. // b103 | | +-+
  89. // | | | +=v2432
  90. // b099 | +-+
  91. // | | +=v2496
  92. // b104 | +-+
  93. // | +=v2560
  94. // b040 +-+
  95. // | | +=v0029
  96. // b060 | +-+
  97. // | +=v0030
  98. // b026 +-+
  99. // | | +=v0045
  100. // b061 | | +-+
  101. // | | | +=v0046
  102. // b041 | +-+
  103. // | +=v0022
  104. // b016 +-+
  105. // | | +=v0023
  106. // b042 | | +-+
  107. // | | | | +=v0047
  108. // b062 | | | +-+
  109. // | | | +=v0048
  110. // b027 | +-+
  111. // | +=v0013
  112. // b008 +-+
  113. // | | +=v0020
  114. // b043 | | +-+
  115. // | | | | +=v0033
  116. // b063 | | | +-+
  117. // | | | +=v0034
  118. // b028 | | +-+
  119. // | | | | +=v0035
  120. // b064 | | | | +-+
  121. // | | | | | +=v0036
  122. // b044 | | | +-+
  123. // | | | | +=v0037
  124. // b065 | | | +-+
  125. // | | | +=v0038
  126. // b017 | +-+
  127. // | | +=v0019
  128. // b045 | | +-+
  129. // | | | | +=v0031
  130. // b066 | | | +-+
  131. // | | | +=v0032
  132. // b029 | +-+
  133. // | +=v0001
  134. // b004 +-+
  135. // | | +=v0012
  136. // b030 | | +-+
  137. // | | | | +=v0053
  138. // b067 | | | | +-+
  139. // | | | | | +=v0054
  140. // b046 | | | +-+
  141. // | | | +=v0026
  142. // b018 | | +-+
  143. // | | | | +=v0039
  144. // b068 | | | | +-+
  145. // | | | | | +=v0040
  146. // b047 | | | | +-+
  147. // | | | | | | +=v0041
  148. // b069 | | | | | +-+
  149. // | | | | | +=v0042
  150. // b031 | | | +-+
  151. // | | | | +=v0043
  152. // b070 | | | | +-+
  153. // | | | | | +=v0044
  154. // b048 | | | +-+
  155. // | | | +=v0021
  156. // b009 | +-+
  157. // | | +=v0028
  158. // b049 | | +-+
  159. // | | | | +=v0061
  160. // b071 | | | +-+
  161. // | | | +=v0062
  162. // b032 | | +-+
  163. // | | | | +=v0063
  164. // b072 | | | | +-+
  165. // | | | | | +=v0000
  166. // b050 | | | +-+
  167. // | | | | +=v0320
  168. // b073 | | | +-+
  169. // | | | +=v0384
  170. // b019 | +-+
  171. // | +=v0010
  172. // b002 +-+
  173. // | | +=v0011
  174. // b020 | | +-+
  175. // | | | | +=v0027
  176. // b051 | | | | +-+
  177. // | | | | | | +=v0059
  178. // b074 | | | | | +-+
  179. // | | | | | +=v0060
  180. // b033 | | | +-+
  181. // | | | | +=v1472
  182. // b086 | | | | +-+
  183. // | | | | | +=v1536
  184. // b075 | | | | +-+
  185. // | | | | | | +=v1600
  186. // b087 | | | | | +-+
  187. // | | | | | +=v1728
  188. // b052 | | | +-+
  189. // | | | +=v0018
  190. // b010 | | +-+
  191. // | | | | +=v0024
  192. // b053 | | | | +-+
  193. // | | | | | | +=v0049
  194. // b076 | | | | | +-+
  195. // | | | | | +=v0050
  196. // b034 | | | | +-+
  197. // | | | | | | +=v0051
  198. // b077 | | | | | | +-+
  199. // | | | | | | | +=v0052
  200. // b054 | | | | | +-+
  201. // | | | | | +=v0025
  202. // b021 | | | +-+
  203. // | | | | +=v0055
  204. // b078 | | | | +-+
  205. // | | | | | +=v0056
  206. // b055 | | | | +-+
  207. // | | | | | | +=v0057
  208. // b079 | | | | | +-+
  209. // | | | | | +=v0058
  210. // b035 | | | +-+
  211. // | | | +=v0192
  212. // b005 | +-+
  213. // | | +=v1664
  214. // b036 | | +-+
  215. // | | | | +=v0448
  216. // b080 | | | | +-+
  217. // | | | | | +=v0512
  218. // b056 | | | +-+
  219. // | | | | +=v0704
  220. // b088 | | | | +-+
  221. // | | | | | +=v0768
  222. // b081 | | | +-+
  223. // | | | +=v0640
  224. // b022 | | +-+
  225. // | | | | +=v0576
  226. // b082 | | | | +-+
  227. // | | | | | | +=v0832
  228. // b089 | | | | | +-+
  229. // | | | | | +=v0896
  230. // b057 | | | | +-+
  231. // | | | | | | +=v0960
  232. // b090 | | | | | | +-+
  233. // | | | | | | | +=v1024
  234. // b083 | | | | | +-+
  235. // | | | | | | +=v1088
  236. // b091 | | | | | +-+
  237. // | | | | | +=v1152
  238. // b037 | | | +-+
  239. // | | | | +=v1216
  240. // b092 | | | | +-+
  241. // | | | | | +=v1280
  242. // b084 | | | | +-+
  243. // | | | | | | +=v1344
  244. // b093 | | | | | +-+
  245. // | | | | | +=v1408
  246. // b058 | | | +-+
  247. // | | | +=v0256
  248. // b011 | +-+
  249. // | +=v0002
  250. // b001 +-+
  251. // | +=v0003
  252. // b012 | +-+
  253. // | | | +=v0128
  254. // b023 | | +-+
  255. // | | +=v0008
  256. // b006 | +-+
  257. // | | | +=v0009
  258. // b024 | | | +-+
  259. // | | | | | +=v0016
  260. // b038 | | | | +-+
  261. // | | | | +=v0017
  262. // b013 | | +-+
  263. // | | +=v0004
  264. // b003 +-+
  265. // | +=v0005
  266. // b014 | +-+
  267. // | | | +=v0014
  268. // b039 | | | +-+
  269. // | | | | +=v0015
  270. // b025 | | +-+
  271. // | | +=v0064
  272. // b007 +-+
  273. // | +=v0006
  274. // b015 +-+
  275. // +=v0007
  276. var whiteDecodeTable = [...][2]int16{
  277. 0: {0, 0},
  278. 1: {2, 3},
  279. 2: {4, 5},
  280. 3: {6, 7},
  281. 4: {8, 9},
  282. 5: {10, 11},
  283. 6: {12, 13},
  284. 7: {14, 15},
  285. 8: {16, 17},
  286. 9: {18, 19},
  287. 10: {20, 21},
  288. 11: {22, ^2},
  289. 12: {^3, 23},
  290. 13: {24, ^4},
  291. 14: {^5, 25},
  292. 15: {^6, ^7},
  293. 16: {26, 27},
  294. 17: {28, 29},
  295. 18: {30, 31},
  296. 19: {32, ^10},
  297. 20: {^11, 33},
  298. 21: {34, 35},
  299. 22: {36, 37},
  300. 23: {^128, ^8},
  301. 24: {^9, 38},
  302. 25: {39, ^64},
  303. 26: {40, 41},
  304. 27: {42, ^13},
  305. 28: {43, 44},
  306. 29: {45, ^1},
  307. 30: {^12, 46},
  308. 31: {47, 48},
  309. 32: {49, 50},
  310. 33: {51, 52},
  311. 34: {53, 54},
  312. 35: {55, ^192},
  313. 36: {^1664, 56},
  314. 37: {57, 58},
  315. 38: {^16, ^17},
  316. 39: {^14, ^15},
  317. 40: {59, 60},
  318. 41: {61, ^22},
  319. 42: {^23, 62},
  320. 43: {^20, 63},
  321. 44: {64, 65},
  322. 45: {^19, 66},
  323. 46: {67, ^26},
  324. 47: {68, 69},
  325. 48: {70, ^21},
  326. 49: {^28, 71},
  327. 50: {72, 73},
  328. 51: {^27, 74},
  329. 52: {75, ^18},
  330. 53: {^24, 76},
  331. 54: {77, ^25},
  332. 55: {78, 79},
  333. 56: {80, 81},
  334. 57: {82, 83},
  335. 58: {84, ^256},
  336. 59: {0, 85},
  337. 60: {^29, ^30},
  338. 61: {^45, ^46},
  339. 62: {^47, ^48},
  340. 63: {^33, ^34},
  341. 64: {^35, ^36},
  342. 65: {^37, ^38},
  343. 66: {^31, ^32},
  344. 67: {^53, ^54},
  345. 68: {^39, ^40},
  346. 69: {^41, ^42},
  347. 70: {^43, ^44},
  348. 71: {^61, ^62},
  349. 72: {^63, ^0},
  350. 73: {^320, ^384},
  351. 74: {^59, ^60},
  352. 75: {86, 87},
  353. 76: {^49, ^50},
  354. 77: {^51, ^52},
  355. 78: {^55, ^56},
  356. 79: {^57, ^58},
  357. 80: {^448, ^512},
  358. 81: {88, ^640},
  359. 82: {^576, 89},
  360. 83: {90, 91},
  361. 84: {92, 93},
  362. 85: {94, 95},
  363. 86: {^1472, ^1536},
  364. 87: {^1600, ^1728},
  365. 88: {^704, ^768},
  366. 89: {^832, ^896},
  367. 90: {^960, ^1024},
  368. 91: {^1088, ^1152},
  369. 92: {^1216, ^1280},
  370. 93: {^1344, ^1408},
  371. 94: {96, 97},
  372. 95: {98, 99},
  373. 96: {^1792, 100},
  374. 97: {101, 102},
  375. 98: {^1856, ^1920},
  376. 99: {103, 104},
  377. 100: {^1984, ^2048},
  378. 101: {^2112, ^2176},
  379. 102: {^2240, ^2304},
  380. 103: {^2368, ^2432},
  381. 104: {^2496, ^2560},
  382. }
  383. // blackDecodeTable represents Tables 2 and 3 for a black run.
  384. //
  385. // +=XXXXX
  386. // b017 +-+
  387. // | | +=v1792
  388. // b042 | | +-+
  389. // | | | | +=v1984
  390. // b063 | | | +-+
  391. // | | | +=v2048
  392. // b029 | | +-+
  393. // | | | | +=v2112
  394. // b064 | | | | +-+
  395. // | | | | | +=v2176
  396. // b043 | | | +-+
  397. // | | | | +=v2240
  398. // b065 | | | +-+
  399. // | | | +=v2304
  400. // b022 | +-+
  401. // | | +=v1856
  402. // b044 | | +-+
  403. // | | | +=v1920
  404. // b030 | +-+
  405. // | | +=v2368
  406. // b066 | | +-+
  407. // | | | +=v2432
  408. // b045 | +-+
  409. // | | +=v2496
  410. // b067 | +-+
  411. // | +=v2560
  412. // b013 +-+
  413. // | | +=v0018
  414. // b031 | | +-+
  415. // | | | | +=v0052
  416. // b068 | | | | +-+
  417. // | | | | | | +=v0640
  418. // b095 | | | | | +-+
  419. // | | | | | +=v0704
  420. // b046 | | | +-+
  421. // | | | | +=v0768
  422. // b096 | | | | +-+
  423. // | | | | | +=v0832
  424. // b069 | | | +-+
  425. // | | | +=v0055
  426. // b023 | | +-+
  427. // | | | | +=v0056
  428. // b070 | | | | +-+
  429. // | | | | | | +=v1280
  430. // b097 | | | | | +-+
  431. // | | | | | +=v1344
  432. // b047 | | | | +-+
  433. // | | | | | | +=v1408
  434. // b098 | | | | | | +-+
  435. // | | | | | | | +=v1472
  436. // b071 | | | | | +-+
  437. // | | | | | +=v0059
  438. // b032 | | | +-+
  439. // | | | | +=v0060
  440. // b072 | | | | +-+
  441. // | | | | | | +=v1536
  442. // b099 | | | | | +-+
  443. // | | | | | +=v1600
  444. // b048 | | | +-+
  445. // | | | +=v0024
  446. // b018 | +-+
  447. // | | +=v0025
  448. // b049 | | +-+
  449. // | | | | +=v1664
  450. // b100 | | | | +-+
  451. // | | | | | +=v1728
  452. // b073 | | | +-+
  453. // | | | +=v0320
  454. // b033 | | +-+
  455. // | | | | +=v0384
  456. // b074 | | | | +-+
  457. // | | | | | +=v0448
  458. // b050 | | | +-+
  459. // | | | | +=v0512
  460. // b101 | | | | +-+
  461. // | | | | | +=v0576
  462. // b075 | | | +-+
  463. // | | | +=v0053
  464. // b024 | +-+
  465. // | | +=v0054
  466. // b076 | | +-+
  467. // | | | | +=v0896
  468. // b102 | | | +-+
  469. // | | | +=v0960
  470. // b051 | | +-+
  471. // | | | | +=v1024
  472. // b103 | | | | +-+
  473. // | | | | | +=v1088
  474. // b077 | | | +-+
  475. // | | | | +=v1152
  476. // b104 | | | +-+
  477. // | | | +=v1216
  478. // b034 | +-+
  479. // | +=v0064
  480. // b010 +-+
  481. // | | +=v0013
  482. // b019 | | +-+
  483. // | | | | +=v0023
  484. // b052 | | | | +-+
  485. // | | | | | | +=v0050
  486. // b078 | | | | | +-+
  487. // | | | | | +=v0051
  488. // b035 | | | | +-+
  489. // | | | | | | +=v0044
  490. // b079 | | | | | | +-+
  491. // | | | | | | | +=v0045
  492. // b053 | | | | | +-+
  493. // | | | | | | +=v0046
  494. // b080 | | | | | +-+
  495. // | | | | | +=v0047
  496. // b025 | | | +-+
  497. // | | | | +=v0057
  498. // b081 | | | | +-+
  499. // | | | | | +=v0058
  500. // b054 | | | | +-+
  501. // | | | | | | +=v0061
  502. // b082 | | | | | +-+
  503. // | | | | | +=v0256
  504. // b036 | | | +-+
  505. // | | | +=v0016
  506. // b014 | +-+
  507. // | | +=v0017
  508. // b037 | | +-+
  509. // | | | | +=v0048
  510. // b083 | | | | +-+
  511. // | | | | | +=v0049
  512. // b055 | | | +-+
  513. // | | | | +=v0062
  514. // b084 | | | +-+
  515. // | | | +=v0063
  516. // b026 | | +-+
  517. // | | | | +=v0030
  518. // b085 | | | | +-+
  519. // | | | | | +=v0031
  520. // b056 | | | | +-+
  521. // | | | | | | +=v0032
  522. // b086 | | | | | +-+
  523. // | | | | | +=v0033
  524. // b038 | | | +-+
  525. // | | | | +=v0040
  526. // b087 | | | | +-+
  527. // | | | | | +=v0041
  528. // b057 | | | +-+
  529. // | | | +=v0022
  530. // b020 | +-+
  531. // | +=v0014
  532. // b008 +-+
  533. // | | +=v0010
  534. // b015 | | +-+
  535. // | | | +=v0011
  536. // b011 | +-+
  537. // | | +=v0015
  538. // b027 | | +-+
  539. // | | | | +=v0128
  540. // b088 | | | | +-+
  541. // | | | | | +=v0192
  542. // b058 | | | | +-+
  543. // | | | | | | +=v0026
  544. // b089 | | | | | +-+
  545. // | | | | | +=v0027
  546. // b039 | | | +-+
  547. // | | | | +=v0028
  548. // b090 | | | | +-+
  549. // | | | | | +=v0029
  550. // b059 | | | +-+
  551. // | | | +=v0019
  552. // b021 | | +-+
  553. // | | | | +=v0020
  554. // b060 | | | | +-+
  555. // | | | | | | +=v0034
  556. // b091 | | | | | +-+
  557. // | | | | | +=v0035
  558. // b040 | | | | +-+
  559. // | | | | | | +=v0036
  560. // b092 | | | | | | +-+
  561. // | | | | | | | +=v0037
  562. // b061 | | | | | +-+
  563. // | | | | | | +=v0038
  564. // b093 | | | | | +-+
  565. // | | | | | +=v0039
  566. // b028 | | | +-+
  567. // | | | | +=v0021
  568. // b062 | | | | +-+
  569. // | | | | | | +=v0042
  570. // b094 | | | | | +-+
  571. // | | | | | +=v0043
  572. // b041 | | | +-+
  573. // | | | +=v0000
  574. // b016 | +-+
  575. // | +=v0012
  576. // b006 +-+
  577. // | | +=v0009
  578. // b012 | | +-+
  579. // | | | +=v0008
  580. // b009 | +-+
  581. // | +=v0007
  582. // b004 +-+
  583. // | | +=v0006
  584. // b007 | +-+
  585. // | +=v0005
  586. // b002 +-+
  587. // | | +=v0001
  588. // b005 | +-+
  589. // | +=v0004
  590. // b001 +-+
  591. // | +=v0003
  592. // b003 +-+
  593. // +=v0002
  594. var blackDecodeTable = [...][2]int16{
  595. 0: {0, 0},
  596. 1: {2, 3},
  597. 2: {4, 5},
  598. 3: {^3, ^2},
  599. 4: {6, 7},
  600. 5: {^1, ^4},
  601. 6: {8, 9},
  602. 7: {^6, ^5},
  603. 8: {10, 11},
  604. 9: {12, ^7},
  605. 10: {13, 14},
  606. 11: {15, 16},
  607. 12: {^9, ^8},
  608. 13: {17, 18},
  609. 14: {19, 20},
  610. 15: {^10, ^11},
  611. 16: {21, ^12},
  612. 17: {0, 22},
  613. 18: {23, 24},
  614. 19: {^13, 25},
  615. 20: {26, ^14},
  616. 21: {27, 28},
  617. 22: {29, 30},
  618. 23: {31, 32},
  619. 24: {33, 34},
  620. 25: {35, 36},
  621. 26: {37, 38},
  622. 27: {^15, 39},
  623. 28: {40, 41},
  624. 29: {42, 43},
  625. 30: {44, 45},
  626. 31: {^18, 46},
  627. 32: {47, 48},
  628. 33: {49, 50},
  629. 34: {51, ^64},
  630. 35: {52, 53},
  631. 36: {54, ^16},
  632. 37: {^17, 55},
  633. 38: {56, 57},
  634. 39: {58, 59},
  635. 40: {60, 61},
  636. 41: {62, ^0},
  637. 42: {^1792, 63},
  638. 43: {64, 65},
  639. 44: {^1856, ^1920},
  640. 45: {66, 67},
  641. 46: {68, 69},
  642. 47: {70, 71},
  643. 48: {72, ^24},
  644. 49: {^25, 73},
  645. 50: {74, 75},
  646. 51: {76, 77},
  647. 52: {^23, 78},
  648. 53: {79, 80},
  649. 54: {81, 82},
  650. 55: {83, 84},
  651. 56: {85, 86},
  652. 57: {87, ^22},
  653. 58: {88, 89},
  654. 59: {90, ^19},
  655. 60: {^20, 91},
  656. 61: {92, 93},
  657. 62: {^21, 94},
  658. 63: {^1984, ^2048},
  659. 64: {^2112, ^2176},
  660. 65: {^2240, ^2304},
  661. 66: {^2368, ^2432},
  662. 67: {^2496, ^2560},
  663. 68: {^52, 95},
  664. 69: {96, ^55},
  665. 70: {^56, 97},
  666. 71: {98, ^59},
  667. 72: {^60, 99},
  668. 73: {100, ^320},
  669. 74: {^384, ^448},
  670. 75: {101, ^53},
  671. 76: {^54, 102},
  672. 77: {103, 104},
  673. 78: {^50, ^51},
  674. 79: {^44, ^45},
  675. 80: {^46, ^47},
  676. 81: {^57, ^58},
  677. 82: {^61, ^256},
  678. 83: {^48, ^49},
  679. 84: {^62, ^63},
  680. 85: {^30, ^31},
  681. 86: {^32, ^33},
  682. 87: {^40, ^41},
  683. 88: {^128, ^192},
  684. 89: {^26, ^27},
  685. 90: {^28, ^29},
  686. 91: {^34, ^35},
  687. 92: {^36, ^37},
  688. 93: {^38, ^39},
  689. 94: {^42, ^43},
  690. 95: {^640, ^704},
  691. 96: {^768, ^832},
  692. 97: {^1280, ^1344},
  693. 98: {^1408, ^1472},
  694. 99: {^1536, ^1600},
  695. 100: {^1664, ^1728},
  696. 101: {^512, ^576},
  697. 102: {^896, ^960},
  698. 103: {^1024, ^1088},
  699. 104: {^1152, ^1216},
  700. }
  701. const maxCodeLength = 13
  702. // Each encodeTable is represented by an array of bitStrings.
  703. // bitString is a pair of uint32 values representing a bit code.
  704. // The nBits low bits of bits make up the actual bit code.
  705. // Eg. bitString{0x0004, 8} represents the bitcode "00000100".
  706. type bitString struct {
  707. bits uint32
  708. nBits uint32
  709. }
  710. // modeEncodeTable represents Table 1 and the End-of-Line code.
  711. var modeEncodeTable = [...]bitString{
  712. 0: {0x0001, 4}, // "0001"
  713. 1: {0x0001, 3}, // "001"
  714. 2: {0x0001, 1}, // "1"
  715. 3: {0x0003, 3}, // "011"
  716. 4: {0x0003, 6}, // "000011"
  717. 5: {0x0003, 7}, // "0000011"
  718. 6: {0x0002, 3}, // "010"
  719. 7: {0x0002, 6}, // "000010"
  720. 8: {0x0002, 7}, // "0000010"
  721. 9: {0x0001, 7}, // "0000001"
  722. }
  723. // whiteEncodeTable2 represents Table 2 for a white run.
  724. var whiteEncodeTable2 = [...]bitString{
  725. 0: {0x0035, 8}, // "00110101"
  726. 1: {0x0007, 6}, // "000111"
  727. 2: {0x0007, 4}, // "0111"
  728. 3: {0x0008, 4}, // "1000"
  729. 4: {0x000b, 4}, // "1011"
  730. 5: {0x000c, 4}, // "1100"
  731. 6: {0x000e, 4}, // "1110"
  732. 7: {0x000f, 4}, // "1111"
  733. 8: {0x0013, 5}, // "10011"
  734. 9: {0x0014, 5}, // "10100"
  735. 10: {0x0007, 5}, // "00111"
  736. 11: {0x0008, 5}, // "01000"
  737. 12: {0x0008, 6}, // "001000"
  738. 13: {0x0003, 6}, // "000011"
  739. 14: {0x0034, 6}, // "110100"
  740. 15: {0x0035, 6}, // "110101"
  741. 16: {0x002a, 6}, // "101010"
  742. 17: {0x002b, 6}, // "101011"
  743. 18: {0x0027, 7}, // "0100111"
  744. 19: {0x000c, 7}, // "0001100"
  745. 20: {0x0008, 7}, // "0001000"
  746. 21: {0x0017, 7}, // "0010111"
  747. 22: {0x0003, 7}, // "0000011"
  748. 23: {0x0004, 7}, // "0000100"
  749. 24: {0x0028, 7}, // "0101000"
  750. 25: {0x002b, 7}, // "0101011"
  751. 26: {0x0013, 7}, // "0010011"
  752. 27: {0x0024, 7}, // "0100100"
  753. 28: {0x0018, 7}, // "0011000"
  754. 29: {0x0002, 8}, // "00000010"
  755. 30: {0x0003, 8}, // "00000011"
  756. 31: {0x001a, 8}, // "00011010"
  757. 32: {0x001b, 8}, // "00011011"
  758. 33: {0x0012, 8}, // "00010010"
  759. 34: {0x0013, 8}, // "00010011"
  760. 35: {0x0014, 8}, // "00010100"
  761. 36: {0x0015, 8}, // "00010101"
  762. 37: {0x0016, 8}, // "00010110"
  763. 38: {0x0017, 8}, // "00010111"
  764. 39: {0x0028, 8}, // "00101000"
  765. 40: {0x0029, 8}, // "00101001"
  766. 41: {0x002a, 8}, // "00101010"
  767. 42: {0x002b, 8}, // "00101011"
  768. 43: {0x002c, 8}, // "00101100"
  769. 44: {0x002d, 8}, // "00101101"
  770. 45: {0x0004, 8}, // "00000100"
  771. 46: {0x0005, 8}, // "00000101"
  772. 47: {0x000a, 8}, // "00001010"
  773. 48: {0x000b, 8}, // "00001011"
  774. 49: {0x0052, 8}, // "01010010"
  775. 50: {0x0053, 8}, // "01010011"
  776. 51: {0x0054, 8}, // "01010100"
  777. 52: {0x0055, 8}, // "01010101"
  778. 53: {0x0024, 8}, // "00100100"
  779. 54: {0x0025, 8}, // "00100101"
  780. 55: {0x0058, 8}, // "01011000"
  781. 56: {0x0059, 8}, // "01011001"
  782. 57: {0x005a, 8}, // "01011010"
  783. 58: {0x005b, 8}, // "01011011"
  784. 59: {0x004a, 8}, // "01001010"
  785. 60: {0x004b, 8}, // "01001011"
  786. 61: {0x0032, 8}, // "00110010"
  787. 62: {0x0033, 8}, // "00110011"
  788. 63: {0x0034, 8}, // "00110100"
  789. }
  790. // whiteEncodeTable3 represents Table 3 for a white run.
  791. var whiteEncodeTable3 = [...]bitString{
  792. 0: {0x001b, 5}, // "11011"
  793. 1: {0x0012, 5}, // "10010"
  794. 2: {0x0017, 6}, // "010111"
  795. 3: {0x0037, 7}, // "0110111"
  796. 4: {0x0036, 8}, // "00110110"
  797. 5: {0x0037, 8}, // "00110111"
  798. 6: {0x0064, 8}, // "01100100"
  799. 7: {0x0065, 8}, // "01100101"
  800. 8: {0x0068, 8}, // "01101000"
  801. 9: {0x0067, 8}, // "01100111"
  802. 10: {0x00cc, 9}, // "011001100"
  803. 11: {0x00cd, 9}, // "011001101"
  804. 12: {0x00d2, 9}, // "011010010"
  805. 13: {0x00d3, 9}, // "011010011"
  806. 14: {0x00d4, 9}, // "011010100"
  807. 15: {0x00d5, 9}, // "011010101"
  808. 16: {0x00d6, 9}, // "011010110"
  809. 17: {0x00d7, 9}, // "011010111"
  810. 18: {0x00d8, 9}, // "011011000"
  811. 19: {0x00d9, 9}, // "011011001"
  812. 20: {0x00da, 9}, // "011011010"
  813. 21: {0x00db, 9}, // "011011011"
  814. 22: {0x0098, 9}, // "010011000"
  815. 23: {0x0099, 9}, // "010011001"
  816. 24: {0x009a, 9}, // "010011010"
  817. 25: {0x0018, 6}, // "011000"
  818. 26: {0x009b, 9}, // "010011011"
  819. 27: {0x0008, 11}, // "00000001000"
  820. 28: {0x000c, 11}, // "00000001100"
  821. 29: {0x000d, 11}, // "00000001101"
  822. 30: {0x0012, 12}, // "000000010010"
  823. 31: {0x0013, 12}, // "000000010011"
  824. 32: {0x0014, 12}, // "000000010100"
  825. 33: {0x0015, 12}, // "000000010101"
  826. 34: {0x0016, 12}, // "000000010110"
  827. 35: {0x0017, 12}, // "000000010111"
  828. 36: {0x001c, 12}, // "000000011100"
  829. 37: {0x001d, 12}, // "000000011101"
  830. 38: {0x001e, 12}, // "000000011110"
  831. 39: {0x001f, 12}, // "000000011111"
  832. }
  833. // blackEncodeTable2 represents Table 2 for a black run.
  834. var blackEncodeTable2 = [...]bitString{
  835. 0: {0x0037, 10}, // "0000110111"
  836. 1: {0x0002, 3}, // "010"
  837. 2: {0x0003, 2}, // "11"
  838. 3: {0x0002, 2}, // "10"
  839. 4: {0x0003, 3}, // "011"
  840. 5: {0x0003, 4}, // "0011"
  841. 6: {0x0002, 4}, // "0010"
  842. 7: {0x0003, 5}, // "00011"
  843. 8: {0x0005, 6}, // "000101"
  844. 9: {0x0004, 6}, // "000100"
  845. 10: {0x0004, 7}, // "0000100"
  846. 11: {0x0005, 7}, // "0000101"
  847. 12: {0x0007, 7}, // "0000111"
  848. 13: {0x0004, 8}, // "00000100"
  849. 14: {0x0007, 8}, // "00000111"
  850. 15: {0x0018, 9}, // "000011000"
  851. 16: {0x0017, 10}, // "0000010111"
  852. 17: {0x0018, 10}, // "0000011000"
  853. 18: {0x0008, 10}, // "0000001000"
  854. 19: {0x0067, 11}, // "00001100111"
  855. 20: {0x0068, 11}, // "00001101000"
  856. 21: {0x006c, 11}, // "00001101100"
  857. 22: {0x0037, 11}, // "00000110111"
  858. 23: {0x0028, 11}, // "00000101000"
  859. 24: {0x0017, 11}, // "00000010111"
  860. 25: {0x0018, 11}, // "00000011000"
  861. 26: {0x00ca, 12}, // "000011001010"
  862. 27: {0x00cb, 12}, // "000011001011"
  863. 28: {0x00cc, 12}, // "000011001100"
  864. 29: {0x00cd, 12}, // "000011001101"
  865. 30: {0x0068, 12}, // "000001101000"
  866. 31: {0x0069, 12}, // "000001101001"
  867. 32: {0x006a, 12}, // "000001101010"
  868. 33: {0x006b, 12}, // "000001101011"
  869. 34: {0x00d2, 12}, // "000011010010"
  870. 35: {0x00d3, 12}, // "000011010011"
  871. 36: {0x00d4, 12}, // "000011010100"
  872. 37: {0x00d5, 12}, // "000011010101"
  873. 38: {0x00d6, 12}, // "000011010110"
  874. 39: {0x00d7, 12}, // "000011010111"
  875. 40: {0x006c, 12}, // "000001101100"
  876. 41: {0x006d, 12}, // "000001101101"
  877. 42: {0x00da, 12}, // "000011011010"
  878. 43: {0x00db, 12}, // "000011011011"
  879. 44: {0x0054, 12}, // "000001010100"
  880. 45: {0x0055, 12}, // "000001010101"
  881. 46: {0x0056, 12}, // "000001010110"
  882. 47: {0x0057, 12}, // "000001010111"
  883. 48: {0x0064, 12}, // "000001100100"
  884. 49: {0x0065, 12}, // "000001100101"
  885. 50: {0x0052, 12}, // "000001010010"
  886. 51: {0x0053, 12}, // "000001010011"
  887. 52: {0x0024, 12}, // "000000100100"
  888. 53: {0x0037, 12}, // "000000110111"
  889. 54: {0x0038, 12}, // "000000111000"
  890. 55: {0x0027, 12}, // "000000100111"
  891. 56: {0x0028, 12}, // "000000101000"
  892. 57: {0x0058, 12}, // "000001011000"
  893. 58: {0x0059, 12}, // "000001011001"
  894. 59: {0x002b, 12}, // "000000101011"
  895. 60: {0x002c, 12}, // "000000101100"
  896. 61: {0x005a, 12}, // "000001011010"
  897. 62: {0x0066, 12}, // "000001100110"
  898. 63: {0x0067, 12}, // "000001100111"
  899. }
  900. // blackEncodeTable3 represents Table 3 for a black run.
  901. var blackEncodeTable3 = [...]bitString{
  902. 0: {0x000f, 10}, // "0000001111"
  903. 1: {0x00c8, 12}, // "000011001000"
  904. 2: {0x00c9, 12}, // "000011001001"
  905. 3: {0x005b, 12}, // "000001011011"
  906. 4: {0x0033, 12}, // "000000110011"
  907. 5: {0x0034, 12}, // "000000110100"
  908. 6: {0x0035, 12}, // "000000110101"
  909. 7: {0x006c, 13}, // "0000001101100"
  910. 8: {0x006d, 13}, // "0000001101101"
  911. 9: {0x004a, 13}, // "0000001001010"
  912. 10: {0x004b, 13}, // "0000001001011"
  913. 11: {0x004c, 13}, // "0000001001100"
  914. 12: {0x004d, 13}, // "0000001001101"
  915. 13: {0x0072, 13}, // "0000001110010"
  916. 14: {0x0073, 13}, // "0000001110011"
  917. 15: {0x0074, 13}, // "0000001110100"
  918. 16: {0x0075, 13}, // "0000001110101"
  919. 17: {0x0076, 13}, // "0000001110110"
  920. 18: {0x0077, 13}, // "0000001110111"
  921. 19: {0x0052, 13}, // "0000001010010"
  922. 20: {0x0053, 13}, // "0000001010011"
  923. 21: {0x0054, 13}, // "0000001010100"
  924. 22: {0x0055, 13}, // "0000001010101"
  925. 23: {0x005a, 13}, // "0000001011010"
  926. 24: {0x005b, 13}, // "0000001011011"
  927. 25: {0x0064, 13}, // "0000001100100"
  928. 26: {0x0065, 13}, // "0000001100101"
  929. 27: {0x0008, 11}, // "00000001000"
  930. 28: {0x000c, 11}, // "00000001100"
  931. 29: {0x000d, 11}, // "00000001101"
  932. 30: {0x0012, 12}, // "000000010010"
  933. 31: {0x0013, 12}, // "000000010011"
  934. 32: {0x0014, 12}, // "000000010100"
  935. 33: {0x0015, 12}, // "000000010101"
  936. 34: {0x0016, 12}, // "000000010110"
  937. 35: {0x0017, 12}, // "000000010111"
  938. 36: {0x001c, 12}, // "000000011100"
  939. 37: {0x001d, 12}, // "000000011101"
  940. 38: {0x001e, 12}, // "000000011110"
  941. 39: {0x001f, 12}, // "000000011111"
  942. }
  943. // COPY PASTE table.go BEGIN
  944. const (
  945. modePass = iota // Pass
  946. modeH // Horizontal
  947. modeV0 // Vertical-0
  948. modeVR1 // Vertical-Right-1
  949. modeVR2 // Vertical-Right-2
  950. modeVR3 // Vertical-Right-3
  951. modeVL1 // Vertical-Left-1
  952. modeVL2 // Vertical-Left-2
  953. modeVL3 // Vertical-Left-3
  954. modeExt // Extension
  955. )
  956. // COPY PASTE table.go END