/src/image/fax/read.go

https://code.google.com/ · Go · 469 lines · 390 code · 43 blank · 36 comment · 69 complexity · 53583a61e17ca24544931dde985ca2ed MD5 · raw file

  1. // Copyright 2011 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Package fax supports CCITT Group 4 image decompression
  5. // as described by ITU-T Recommendation T.6.
  6. // See http://www.itu.int/rec/T-REC-T.6-198811-I
  7. package fax
  8. import (
  9. "errors"
  10. "image"
  11. "io"
  12. )
  13. const (
  14. white = 0xFF
  15. black = 0x00
  16. )
  17. var negativeWidth = errors.New("fax: negative width specified")
  18. // DecodeG4 parses a Group 4 fax image from reader.
  19. // The width will be applied as specified and the
  20. // (estimated) height helps memory allocation.
  21. func DecodeG4(reader io.ByteReader, width, height int) (image.Image, error) {
  22. if width < 0 {
  23. return nil, negativeWidth
  24. }
  25. if width == 0 {
  26. return new(image.Gray), nil
  27. }
  28. if height <= 0 {
  29. height = width
  30. }
  31. // include imaginary first line
  32. height++
  33. pixels := make([]byte, width, width*height)
  34. for i := width - 1; i >= 0; i-- {
  35. pixels[i] = white
  36. }
  37. d := &decoder{
  38. reader: reader,
  39. pixels: pixels,
  40. width: width,
  41. atNewLine: true,
  42. color: white,
  43. }
  44. // initiate d.head
  45. if err := d.pop(0); err != nil {
  46. return nil, err
  47. }
  48. return d.parse()
  49. }
  50. type decoder struct {
  51. // reader is the data source
  52. reader io.ByteReader
  53. // head contains the current data in the stream.
  54. // The first upcoming bit is packed in the 32nd bit, the
  55. // second upcoming bit in the 31st, etc.
  56. head uint
  57. // bitCount is the number of bits loaded in head.
  58. bitCount uint
  59. // pixels are black and white values.
  60. pixels []byte
  61. // width is the line length in pixels.
  62. width int
  63. // atNewLine is whether a0 is before the beginning of a line.
  64. atNewLine bool
  65. // color represents the state of a0.
  66. color byte
  67. }
  68. // pop advances n bits in the stream.
  69. // The 24-bit end-of-facsimile block exceeds all
  70. // Huffman codes in length.
  71. func (d *decoder) pop(n uint) error {
  72. head := d.head
  73. count := d.bitCount
  74. head <<= n
  75. count -= n
  76. for count < 24 {
  77. next, err := d.reader.ReadByte()
  78. if err != nil {
  79. return err
  80. }
  81. head |= uint(next) << (24 - count)
  82. count += 8
  83. }
  84. d.head = head
  85. d.bitCount = count
  86. return nil
  87. }
  88. // paint adds n d.pixels in the specified color.
  89. func (d *decoder) paint(n int, color byte) {
  90. a := d.pixels
  91. for ; n != 0; n-- {
  92. a = append(a, color)
  93. }
  94. d.pixels = a
  95. }
  96. func (d *decoder) parse() (result image.Image, err error) {
  97. // parse until end-of-facsimile block: 0x001001
  98. for d.head&0xFE000000 != 0 && err == nil {
  99. i := (d.head >> 28) & 0xF
  100. err = modeTable[i](d)
  101. }
  102. width := d.width
  103. pixels := d.pixels[width:] // strip imaginary line
  104. bounds := image.Rect(0, 0, width, len(pixels)/width)
  105. result = &image.Gray{pixels, width, bounds}
  106. return
  107. }
  108. var modeTable = [16]func(d *decoder) error{
  109. func(d *decoder) error {
  110. i := (d.head >> 25) & 7
  111. return modeTable2[i](d)
  112. },
  113. pass,
  114. horizontal,
  115. horizontal,
  116. verticalLeft1,
  117. verticalLeft1,
  118. verticalRight1,
  119. verticalRight1,
  120. vertical0, vertical0, vertical0, vertical0,
  121. vertical0, vertical0, vertical0, vertical0,
  122. }
  123. var modeTable2 = [8]func(d *decoder) error{
  124. nil,
  125. extension,
  126. verticalLeft3,
  127. verticalRight3,
  128. verticalLeft2,
  129. verticalLeft2,
  130. verticalRight2,
  131. verticalRight2,
  132. }
  133. func pass(d *decoder) error {
  134. if e := d.pop(4); e != nil {
  135. return e
  136. }
  137. color := d.color
  138. width := d.width
  139. pixels := d.pixels
  140. a := len(pixels)
  141. lineStart := (a / width) * width
  142. b := a - width // reference element
  143. if !d.atNewLine {
  144. for b != lineStart && pixels[b] != color {
  145. b++
  146. }
  147. }
  148. for b != lineStart && pixels[b] == color {
  149. b++
  150. }
  151. // found b1
  152. for b != lineStart && pixels[b] != color {
  153. b++
  154. }
  155. // found b2
  156. if b == lineStart {
  157. d.atNewLine = true
  158. d.color = white
  159. } else {
  160. d.atNewLine = false
  161. }
  162. d.paint(b-a+width, color)
  163. return nil
  164. }
  165. func vertical0(d *decoder) error {
  166. d.vertical(0)
  167. return d.pop(1)
  168. }
  169. func verticalLeft1(d *decoder) error {
  170. d.vertical(-1)
  171. return d.pop(3)
  172. }
  173. func verticalLeft2(d *decoder) error {
  174. d.vertical(-2)
  175. return d.pop(6)
  176. }
  177. func verticalLeft3(d *decoder) error {
  178. d.vertical(-3)
  179. return d.pop(7)
  180. }
  181. func verticalRight1(d *decoder) error {
  182. d.vertical(1)
  183. return d.pop(3)
  184. }
  185. func verticalRight2(d *decoder) error {
  186. d.vertical(2)
  187. return d.pop(6)
  188. }
  189. func verticalRight3(d *decoder) error {
  190. d.vertical(3)
  191. return d.pop(7)
  192. }
  193. func (d *decoder) vertical(offset int) {
  194. color := d.color
  195. width := d.width
  196. pixels := d.pixels
  197. a := len(pixels)
  198. lineStart := (a / width) * width
  199. b := a - width // reference element
  200. if !d.atNewLine {
  201. for b != lineStart && pixels[b] != color {
  202. b++
  203. }
  204. }
  205. for b != lineStart && pixels[b] == color {
  206. b++
  207. }
  208. // found b1
  209. b += offset
  210. if b >= lineStart {
  211. b = lineStart
  212. d.atNewLine = true
  213. d.color = white
  214. } else {
  215. d.atNewLine = false
  216. d.color = color ^ 0xFF
  217. }
  218. if count := b - a + width; count >= 0 {
  219. d.paint(count, color)
  220. }
  221. }
  222. func horizontal(d *decoder) (err error) {
  223. if err = d.pop(3); err != nil {
  224. return
  225. }
  226. color := d.color
  227. flip := color ^ 0xFF
  228. var rl1, rl2 int
  229. if rl1, err = d.runLength(color); err == nil {
  230. rl2, err = d.runLength(flip)
  231. }
  232. // pixels left in the line:
  233. remaining := d.width - (len(d.pixels) % d.width)
  234. if rl1 > remaining {
  235. rl1 = remaining
  236. }
  237. d.paint(rl1, color)
  238. remaining -= rl1
  239. if rl2 >= remaining {
  240. rl2 = remaining
  241. d.atNewLine = true
  242. d.color = white
  243. } else {
  244. d.atNewLine = false
  245. }
  246. d.paint(rl2, flip)
  247. return
  248. }
  249. // runLength reads the amount of pixels for a color.
  250. func (d *decoder) runLength(color byte) (count int, err error) {
  251. match := uint16(0xFFFF) // lookup entry
  252. for match&0xFC0 != 0 && err == nil {
  253. if color == black {
  254. if d.head&0xF0000000 != 0 {
  255. match = blackShortLookup[(d.head>>26)&0x3F]
  256. } else if d.head&0xFE000000 != 0 {
  257. match = blackLookup[(d.head>>19)&0x1FF]
  258. } else {
  259. match = sharedLookup[(d.head>>20)&0x1F]
  260. }
  261. } else {
  262. if d.head&0xFE000000 != 0 {
  263. match = whiteLookup[(d.head>>23)&0x1FF]
  264. } else {
  265. match = sharedLookup[(d.head>>20)&0x1F]
  266. }
  267. }
  268. err = d.pop(uint(match) >> 12)
  269. count += int(match) & 0x0FFF
  270. }
  271. return
  272. }
  273. // Lookup tables are used by runLength to find Huffman codes. Their index
  274. // size is large enough to fit the longest code in the group. Shorter codes
  275. // have duplicate entries with all possible tailing bits.
  276. // Entries consist of two parts. The 4 most significant bits contain the
  277. // Huffman code length in bits and the 12 least significant bits contain
  278. // the pixel count.
  279. var blackShortLookup = [64]uint16{
  280. 0x0, 0x0, 0x0, 0x0, 0x6009, 0x6008, 0x5007, 0x5007,
  281. 0x4006, 0x4006, 0x4006, 0x4006, 0x4005, 0x4005, 0x4005, 0x4005,
  282. 0x3001, 0x3001, 0x3001, 0x3001, 0x3001, 0x3001, 0x3001, 0x3001,
  283. 0x3004, 0x3004, 0x3004, 0x3004, 0x3004, 0x3004, 0x3004, 0x3004,
  284. 0x2003, 0x2003, 0x2003, 0x2003, 0x2003, 0x2003, 0x2003, 0x2003,
  285. 0x2003, 0x2003, 0x2003, 0x2003, 0x2003, 0x2003, 0x2003, 0x2003,
  286. 0x2002, 0x2002, 0x2002, 0x2002, 0x2002, 0x2002, 0x2002, 0x2002,
  287. 0x2002, 0x2002, 0x2002, 0x2002, 0x2002, 0x2002, 0x2002, 0x2002,
  288. }
  289. var blackLookup = [512]uint16{
  290. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  291. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  292. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  293. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  294. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  295. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  296. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  297. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  298. 0xa012, 0xa012, 0xa012, 0xa012, 0xa012, 0xa012, 0xa012, 0xa012,
  299. 0xc034, 0xc034, 0xd280, 0xd2c0, 0xd300, 0xd340, 0xc037, 0xc037,
  300. 0xc038, 0xc038, 0xd500, 0xd540, 0xd580, 0xd5c0, 0xc03b, 0xc03b,
  301. 0xc03c, 0xc03c, 0xd600, 0xd640, 0xb018, 0xb018, 0xb018, 0xb018,
  302. 0xb019, 0xb019, 0xb019, 0xb019, 0xd680, 0xd6c0, 0xc140, 0xc140,
  303. 0xc180, 0xc180, 0xc1c0, 0xc1c0, 0xd200, 0xd240, 0xc035, 0xc035,
  304. 0xc036, 0xc036, 0xd380, 0xd3c0, 0xd400, 0xd440, 0xd480, 0xd4c0,
  305. 0xa040, 0xa040, 0xa040, 0xa040, 0xa040, 0xa040, 0xa040, 0xa040,
  306. 0x800d, 0x800d, 0x800d, 0x800d, 0x800d, 0x800d, 0x800d, 0x800d,
  307. 0x800d, 0x800d, 0x800d, 0x800d, 0x800d, 0x800d, 0x800d, 0x800d,
  308. 0x800d, 0x800d, 0x800d, 0x800d, 0x800d, 0x800d, 0x800d, 0x800d,
  309. 0x800d, 0x800d, 0x800d, 0x800d, 0x800d, 0x800d, 0x800d, 0x800d,
  310. 0xb017, 0xb017, 0xb017, 0xb017, 0xc032, 0xc032, 0xc033, 0xc033,
  311. 0xc02c, 0xc02c, 0xc02d, 0xc02d, 0xc02e, 0xc02e, 0xc02f, 0xc02f,
  312. 0xc039, 0xc039, 0xc03a, 0xc03a, 0xc03d, 0xc03d, 0xc100, 0xc100,
  313. 0xa010, 0xa010, 0xa010, 0xa010, 0xa010, 0xa010, 0xa010, 0xa010,
  314. 0xa011, 0xa011, 0xa011, 0xa011, 0xa011, 0xa011, 0xa011, 0xa011,
  315. 0xc030, 0xc030, 0xc031, 0xc031, 0xc03e, 0xc03e, 0xc03f, 0xc03f,
  316. 0xc01e, 0xc01e, 0xc01f, 0xc01f, 0xc020, 0xc020, 0xc021, 0xc021,
  317. 0xc028, 0xc028, 0xc029, 0xc029, 0xb016, 0xb016, 0xb016, 0xb016,
  318. 0x800e, 0x800e, 0x800e, 0x800e, 0x800e, 0x800e, 0x800e, 0x800e,
  319. 0x800e, 0x800e, 0x800e, 0x800e, 0x800e, 0x800e, 0x800e, 0x800e,
  320. 0x800e, 0x800e, 0x800e, 0x800e, 0x800e, 0x800e, 0x800e, 0x800e,
  321. 0x800e, 0x800e, 0x800e, 0x800e, 0x800e, 0x800e, 0x800e, 0x800e,
  322. 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a,
  323. 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a,
  324. 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a,
  325. 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a,
  326. 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a,
  327. 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a,
  328. 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a,
  329. 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a, 0x700a,
  330. 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b,
  331. 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b,
  332. 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b,
  333. 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b,
  334. 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b,
  335. 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b,
  336. 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b,
  337. 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b, 0x700b,
  338. 0x900f, 0x900f, 0x900f, 0x900f, 0x900f, 0x900f, 0x900f, 0x900f,
  339. 0x900f, 0x900f, 0x900f, 0x900f, 0x900f, 0x900f, 0x900f, 0x900f,
  340. 0xc080, 0xc080, 0xc0c0, 0xc0c0, 0xc01a, 0xc01a, 0xc01b, 0xc01b,
  341. 0xc01c, 0xc01c, 0xc01d, 0xc01d, 0xb013, 0xb013, 0xb013, 0xb013,
  342. 0xb014, 0xb014, 0xb014, 0xb014, 0xc022, 0xc022, 0xc023, 0xc023,
  343. 0xc024, 0xc024, 0xc025, 0xc025, 0xc026, 0xc026, 0xc027, 0xc027,
  344. 0xb015, 0xb015, 0xb015, 0xb015, 0xc02a, 0xc02a, 0xc02b, 0xc02b,
  345. 0xa000, 0xa000, 0xa000, 0xa000, 0xa000, 0xa000, 0xa000, 0xa000,
  346. 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c,
  347. 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c,
  348. 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c,
  349. 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c,
  350. 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c,
  351. 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c,
  352. 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c,
  353. 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c, 0x700c,
  354. }
  355. var whiteLookup = [512]uint16{
  356. 0x0, 0x0, 0x0, 0x0, 0x801d, 0x801d, 0x801e, 0x801e,
  357. 0x802d, 0x802d, 0x802e, 0x802e, 0x7016, 0x7016, 0x7016, 0x7016,
  358. 0x7017, 0x7017, 0x7017, 0x7017, 0x802f, 0x802f, 0x8030, 0x8030,
  359. 0x600d, 0x600d, 0x600d, 0x600d, 0x600d, 0x600d, 0x600d, 0x600d,
  360. 0x7014, 0x7014, 0x7014, 0x7014, 0x8021, 0x8021, 0x8022, 0x8022,
  361. 0x8023, 0x8023, 0x8024, 0x8024, 0x8025, 0x8025, 0x8026, 0x8026,
  362. 0x7013, 0x7013, 0x7013, 0x7013, 0x801f, 0x801f, 0x8020, 0x8020,
  363. 0x6001, 0x6001, 0x6001, 0x6001, 0x6001, 0x6001, 0x6001, 0x6001,
  364. 0x600c, 0x600c, 0x600c, 0x600c, 0x600c, 0x600c, 0x600c, 0x600c,
  365. 0x8035, 0x8035, 0x8036, 0x8036, 0x701a, 0x701a, 0x701a, 0x701a,
  366. 0x8027, 0x8027, 0x8028, 0x8028, 0x8029, 0x8029, 0x802a, 0x802a,
  367. 0x802b, 0x802b, 0x802c, 0x802c, 0x7015, 0x7015, 0x7015, 0x7015,
  368. 0x701c, 0x701c, 0x701c, 0x701c, 0x803d, 0x803d, 0x803e, 0x803e,
  369. 0x803f, 0x803f, 0x8000, 0x8000, 0x8140, 0x8140, 0x8180, 0x8180,
  370. 0x500a, 0x500a, 0x500a, 0x500a, 0x500a, 0x500a, 0x500a, 0x500a,
  371. 0x500a, 0x500a, 0x500a, 0x500a, 0x500a, 0x500a, 0x500a, 0x500a,
  372. 0x500b, 0x500b, 0x500b, 0x500b, 0x500b, 0x500b, 0x500b, 0x500b,
  373. 0x500b, 0x500b, 0x500b, 0x500b, 0x500b, 0x500b, 0x500b, 0x500b,
  374. 0x701b, 0x701b, 0x701b, 0x701b, 0x803b, 0x803b, 0x803c, 0x803c,
  375. 0x95c0, 0x9600, 0x9640, 0x96c0, 0x7012, 0x7012, 0x7012, 0x7012,
  376. 0x7018, 0x7018, 0x7018, 0x7018, 0x8031, 0x8031, 0x8032, 0x8032,
  377. 0x8033, 0x8033, 0x8034, 0x8034, 0x7019, 0x7019, 0x7019, 0x7019,
  378. 0x8037, 0x8037, 0x8038, 0x8038, 0x8039, 0x8039, 0x803a, 0x803a,
  379. 0x60c0, 0x60c0, 0x60c0, 0x60c0, 0x60c0, 0x60c0, 0x60c0, 0x60c0,
  380. 0x6680, 0x6680, 0x6680, 0x6680, 0x6680, 0x6680, 0x6680, 0x6680,
  381. 0x81c0, 0x81c0, 0x8200, 0x8200, 0x92c0, 0x9300, 0x8280, 0x8280,
  382. 0x8240, 0x8240, 0x9340, 0x9380, 0x93c0, 0x9400, 0x9440, 0x9480,
  383. 0x94c0, 0x9500, 0x9540, 0x9580, 0x7100, 0x7100, 0x7100, 0x7100,
  384. 0x4002, 0x4002, 0x4002, 0x4002, 0x4002, 0x4002, 0x4002, 0x4002,
  385. 0x4002, 0x4002, 0x4002, 0x4002, 0x4002, 0x4002, 0x4002, 0x4002,
  386. 0x4002, 0x4002, 0x4002, 0x4002, 0x4002, 0x4002, 0x4002, 0x4002,
  387. 0x4002, 0x4002, 0x4002, 0x4002, 0x4002, 0x4002, 0x4002, 0x4002,
  388. 0x4003, 0x4003, 0x4003, 0x4003, 0x4003, 0x4003, 0x4003, 0x4003,
  389. 0x4003, 0x4003, 0x4003, 0x4003, 0x4003, 0x4003, 0x4003, 0x4003,
  390. 0x4003, 0x4003, 0x4003, 0x4003, 0x4003, 0x4003, 0x4003, 0x4003,
  391. 0x4003, 0x4003, 0x4003, 0x4003, 0x4003, 0x4003, 0x4003, 0x4003,
  392. 0x5080, 0x5080, 0x5080, 0x5080, 0x5080, 0x5080, 0x5080, 0x5080,
  393. 0x5080, 0x5080, 0x5080, 0x5080, 0x5080, 0x5080, 0x5080, 0x5080,
  394. 0x5008, 0x5008, 0x5008, 0x5008, 0x5008, 0x5008, 0x5008, 0x5008,
  395. 0x5008, 0x5008, 0x5008, 0x5008, 0x5008, 0x5008, 0x5008, 0x5008,
  396. 0x5009, 0x5009, 0x5009, 0x5009, 0x5009, 0x5009, 0x5009, 0x5009,
  397. 0x5009, 0x5009, 0x5009, 0x5009, 0x5009, 0x5009, 0x5009, 0x5009,
  398. 0x6010, 0x6010, 0x6010, 0x6010, 0x6010, 0x6010, 0x6010, 0x6010,
  399. 0x6011, 0x6011, 0x6011, 0x6011, 0x6011, 0x6011, 0x6011, 0x6011,
  400. 0x4004, 0x4004, 0x4004, 0x4004, 0x4004, 0x4004, 0x4004, 0x4004,
  401. 0x4004, 0x4004, 0x4004, 0x4004, 0x4004, 0x4004, 0x4004, 0x4004,
  402. 0x4004, 0x4004, 0x4004, 0x4004, 0x4004, 0x4004, 0x4004, 0x4004,
  403. 0x4004, 0x4004, 0x4004, 0x4004, 0x4004, 0x4004, 0x4004, 0x4004,
  404. 0x4005, 0x4005, 0x4005, 0x4005, 0x4005, 0x4005, 0x4005, 0x4005,
  405. 0x4005, 0x4005, 0x4005, 0x4005, 0x4005, 0x4005, 0x4005, 0x4005,
  406. 0x4005, 0x4005, 0x4005, 0x4005, 0x4005, 0x4005, 0x4005, 0x4005,
  407. 0x4005, 0x4005, 0x4005, 0x4005, 0x4005, 0x4005, 0x4005, 0x4005,
  408. 0x600e, 0x600e, 0x600e, 0x600e, 0x600e, 0x600e, 0x600e, 0x600e,
  409. 0x600f, 0x600f, 0x600f, 0x600f, 0x600f, 0x600f, 0x600f, 0x600f,
  410. 0x5040, 0x5040, 0x5040, 0x5040, 0x5040, 0x5040, 0x5040, 0x5040,
  411. 0x5040, 0x5040, 0x5040, 0x5040, 0x5040, 0x5040, 0x5040, 0x5040,
  412. 0x4006, 0x4006, 0x4006, 0x4006, 0x4006, 0x4006, 0x4006, 0x4006,
  413. 0x4006, 0x4006, 0x4006, 0x4006, 0x4006, 0x4006, 0x4006, 0x4006,
  414. 0x4006, 0x4006, 0x4006, 0x4006, 0x4006, 0x4006, 0x4006, 0x4006,
  415. 0x4006, 0x4006, 0x4006, 0x4006, 0x4006, 0x4006, 0x4006, 0x4006,
  416. 0x4007, 0x4007, 0x4007, 0x4007, 0x4007, 0x4007, 0x4007, 0x4007,
  417. 0x4007, 0x4007, 0x4007, 0x4007, 0x4007, 0x4007, 0x4007, 0x4007,
  418. 0x4007, 0x4007, 0x4007, 0x4007, 0x4007, 0x4007, 0x4007, 0x4007,
  419. 0x4007, 0x4007, 0x4007, 0x4007, 0x4007, 0x4007, 0x4007, 0x4007,
  420. }
  421. var sharedLookup = [32]uint16{
  422. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  423. 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
  424. 0xb700, 0xb700, 0xc7c0, 0xc800, 0xc840, 0xc880, 0xc8c0, 0xc900,
  425. 0xb740, 0xb740, 0xb780, 0xb780, 0xc940, 0xc980, 0xc9c0, 0xca00,
  426. }