version.go 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050
  1. // go-qrcode
  2. // Copyright 2014 Tom Harwood
  3. package qrcode
  4. import (
  5. "log"
  6. bitset "github.com/skip2/go-qrcode/bitset"
  7. )
  8. // Error detection/recovery capacity.
  9. //
  10. // There are several levels of error detection/recovery capacity. Higher levels
  11. // of error recovery are able to correct more errors, with the trade-off of
  12. // increased symbol size.
  13. type RecoveryLevel int
  14. const (
  15. // Level L: 7% error recovery.
  16. Low RecoveryLevel = iota
  17. // Level M: 15% error recovery. Good default choice.
  18. Medium
  19. // Level Q: 25% error recovery.
  20. High
  21. // Level H: 30% error recovery.
  22. Highest
  23. )
  24. // qrCodeVersion describes the data length and encoding order of a single QR
  25. // Code version. There are 40 versions numbers x 4 recovery levels == 160
  26. // possible qrCodeVersion structures.
  27. type qrCodeVersion struct {
  28. // Version number (1-40 inclusive).
  29. version int
  30. // Error recovery level.
  31. level RecoveryLevel
  32. dataEncoderType dataEncoderType
  33. // Encoded data can be split into multiple blocks. Each block contains data
  34. // and error recovery bytes.
  35. //
  36. // Larger QR Codes contain more blocks.
  37. block []block
  38. // Number of bits required to pad the combined data & error correction bit
  39. // stream up to the symbol's full capacity.
  40. numRemainderBits int
  41. }
  42. type block struct {
  43. numBlocks int
  44. // Total codewords (numCodewords == numErrorCodewords+numDataCodewords).
  45. numCodewords int
  46. // Number of data codewords.
  47. numDataCodewords int
  48. }
  49. var (
  50. versions = []qrCodeVersion{
  51. {
  52. 1,
  53. Low,
  54. dataEncoderType1To9,
  55. []block{
  56. {
  57. 1,
  58. 26,
  59. 19,
  60. },
  61. },
  62. 0,
  63. },
  64. {
  65. 1,
  66. Medium,
  67. dataEncoderType1To9,
  68. []block{
  69. {
  70. 1,
  71. 26,
  72. 16,
  73. },
  74. },
  75. 0,
  76. },
  77. {
  78. 1,
  79. High,
  80. dataEncoderType1To9,
  81. []block{
  82. {
  83. 1,
  84. 26,
  85. 13,
  86. },
  87. },
  88. 0,
  89. },
  90. {
  91. 1,
  92. Highest,
  93. dataEncoderType1To9,
  94. []block{
  95. {
  96. 1,
  97. 26,
  98. 9,
  99. },
  100. },
  101. 0,
  102. },
  103. {
  104. 2,
  105. Low,
  106. dataEncoderType1To9,
  107. []block{
  108. {
  109. 1,
  110. 44,
  111. 34,
  112. },
  113. },
  114. 7,
  115. },
  116. {
  117. 2,
  118. Medium,
  119. dataEncoderType1To9,
  120. []block{
  121. {
  122. 1,
  123. 44,
  124. 28,
  125. },
  126. },
  127. 7,
  128. },
  129. {
  130. 2,
  131. High,
  132. dataEncoderType1To9,
  133. []block{
  134. {
  135. 1,
  136. 44,
  137. 22,
  138. },
  139. },
  140. 7,
  141. },
  142. {
  143. 2,
  144. Highest,
  145. dataEncoderType1To9,
  146. []block{
  147. {
  148. 1,
  149. 44,
  150. 16,
  151. },
  152. },
  153. 7,
  154. },
  155. {
  156. 3,
  157. Low,
  158. dataEncoderType1To9,
  159. []block{
  160. {
  161. 1,
  162. 70,
  163. 55,
  164. },
  165. },
  166. 7,
  167. },
  168. {
  169. 3,
  170. Medium,
  171. dataEncoderType1To9,
  172. []block{
  173. {
  174. 1,
  175. 70,
  176. 44,
  177. },
  178. },
  179. 7,
  180. },
  181. {
  182. 3,
  183. High,
  184. dataEncoderType1To9,
  185. []block{
  186. {
  187. 2,
  188. 35,
  189. 17,
  190. },
  191. },
  192. 7,
  193. },
  194. {
  195. 3,
  196. Highest,
  197. dataEncoderType1To9,
  198. []block{
  199. {
  200. 2,
  201. 35,
  202. 13,
  203. },
  204. },
  205. 7,
  206. },
  207. {
  208. 4,
  209. Low,
  210. dataEncoderType1To9,
  211. []block{
  212. {
  213. 1,
  214. 100,
  215. 80,
  216. },
  217. },
  218. 7,
  219. },
  220. {
  221. 4,
  222. Medium,
  223. dataEncoderType1To9,
  224. []block{
  225. {
  226. 2,
  227. 50,
  228. 32,
  229. },
  230. },
  231. 7,
  232. },
  233. {
  234. 4,
  235. High,
  236. dataEncoderType1To9,
  237. []block{
  238. {
  239. 2,
  240. 50,
  241. 24,
  242. },
  243. },
  244. 7,
  245. },
  246. {
  247. 4,
  248. Highest,
  249. dataEncoderType1To9,
  250. []block{
  251. {
  252. 4,
  253. 25,
  254. 9,
  255. },
  256. },
  257. 7,
  258. },
  259. {
  260. 5,
  261. Low,
  262. dataEncoderType1To9,
  263. []block{
  264. {
  265. 1,
  266. 134,
  267. 108,
  268. },
  269. },
  270. 7,
  271. },
  272. {
  273. 5,
  274. Medium,
  275. dataEncoderType1To9,
  276. []block{
  277. {
  278. 2,
  279. 67,
  280. 43,
  281. },
  282. },
  283. 7,
  284. },
  285. {
  286. 5,
  287. High,
  288. dataEncoderType1To9,
  289. []block{
  290. {
  291. 2,
  292. 33,
  293. 15,
  294. },
  295. {
  296. 2,
  297. 34,
  298. 16,
  299. },
  300. },
  301. 7,
  302. },
  303. {
  304. 5,
  305. Highest,
  306. dataEncoderType1To9,
  307. []block{
  308. {
  309. 2,
  310. 33,
  311. 11,
  312. },
  313. {
  314. 2,
  315. 34,
  316. 12,
  317. },
  318. },
  319. 7,
  320. },
  321. {
  322. 6,
  323. Low,
  324. dataEncoderType1To9,
  325. []block{
  326. {
  327. 2,
  328. 86,
  329. 68,
  330. },
  331. },
  332. 7,
  333. },
  334. {
  335. 6,
  336. Medium,
  337. dataEncoderType1To9,
  338. []block{
  339. {
  340. 4,
  341. 43,
  342. 27,
  343. },
  344. },
  345. 7,
  346. },
  347. {
  348. 6,
  349. High,
  350. dataEncoderType1To9,
  351. []block{
  352. {
  353. 4,
  354. 43,
  355. 19,
  356. },
  357. },
  358. 7,
  359. },
  360. {
  361. 6,
  362. Highest,
  363. dataEncoderType1To9,
  364. []block{
  365. {
  366. 4,
  367. 43,
  368. 15,
  369. },
  370. },
  371. 7,
  372. },
  373. {
  374. 7,
  375. Low,
  376. dataEncoderType1To9,
  377. []block{
  378. {
  379. 2,
  380. 98,
  381. 78,
  382. },
  383. },
  384. 0,
  385. },
  386. {
  387. 7,
  388. Medium,
  389. dataEncoderType1To9,
  390. []block{
  391. {
  392. 4,
  393. 49,
  394. 31,
  395. },
  396. },
  397. 0,
  398. },
  399. {
  400. 7,
  401. High,
  402. dataEncoderType1To9,
  403. []block{
  404. {
  405. 2,
  406. 32,
  407. 14,
  408. },
  409. {
  410. 4,
  411. 33,
  412. 15,
  413. },
  414. },
  415. 0,
  416. },
  417. {
  418. 7,
  419. Highest,
  420. dataEncoderType1To9,
  421. []block{
  422. {
  423. 4,
  424. 39,
  425. 13,
  426. },
  427. {
  428. 1,
  429. 40,
  430. 14,
  431. },
  432. },
  433. 0,
  434. },
  435. {
  436. 8,
  437. Low,
  438. dataEncoderType1To9,
  439. []block{
  440. {
  441. 2,
  442. 121,
  443. 97,
  444. },
  445. },
  446. 0,
  447. },
  448. {
  449. 8,
  450. Medium,
  451. dataEncoderType1To9,
  452. []block{
  453. {
  454. 2,
  455. 60,
  456. 38,
  457. },
  458. {
  459. 2,
  460. 61,
  461. 39,
  462. },
  463. },
  464. 0,
  465. },
  466. {
  467. 8,
  468. High,
  469. dataEncoderType1To9,
  470. []block{
  471. {
  472. 4,
  473. 40,
  474. 18,
  475. },
  476. {
  477. 2,
  478. 41,
  479. 19,
  480. },
  481. },
  482. 0,
  483. },
  484. {
  485. 8,
  486. Highest,
  487. dataEncoderType1To9,
  488. []block{
  489. {
  490. 4,
  491. 40,
  492. 14,
  493. },
  494. {
  495. 2,
  496. 41,
  497. 15,
  498. },
  499. },
  500. 0,
  501. },
  502. {
  503. 9,
  504. Low,
  505. dataEncoderType1To9,
  506. []block{
  507. {
  508. 2,
  509. 146,
  510. 116,
  511. },
  512. },
  513. 0,
  514. },
  515. {
  516. 9,
  517. Medium,
  518. dataEncoderType1To9,
  519. []block{
  520. {
  521. 3,
  522. 58,
  523. 36,
  524. },
  525. {
  526. 2,
  527. 59,
  528. 37,
  529. },
  530. },
  531. 0,
  532. },
  533. {
  534. 9,
  535. High,
  536. dataEncoderType1To9,
  537. []block{
  538. {
  539. 4,
  540. 36,
  541. 16,
  542. },
  543. {
  544. 4,
  545. 37,
  546. 17,
  547. },
  548. },
  549. 0,
  550. },
  551. {
  552. 9,
  553. Highest,
  554. dataEncoderType1To9,
  555. []block{
  556. {
  557. 4,
  558. 36,
  559. 12,
  560. },
  561. {
  562. 4,
  563. 37,
  564. 13,
  565. },
  566. },
  567. 0,
  568. },
  569. {
  570. 10,
  571. Low,
  572. dataEncoderType10To26,
  573. []block{
  574. {
  575. 2,
  576. 86,
  577. 68,
  578. },
  579. {
  580. 2,
  581. 87,
  582. 69,
  583. },
  584. },
  585. 0,
  586. },
  587. {
  588. 10,
  589. Medium,
  590. dataEncoderType10To26,
  591. []block{
  592. {
  593. 4,
  594. 69,
  595. 43,
  596. },
  597. {
  598. 1,
  599. 70,
  600. 44,
  601. },
  602. },
  603. 0,
  604. },
  605. {
  606. 10,
  607. High,
  608. dataEncoderType10To26,
  609. []block{
  610. {
  611. 6,
  612. 43,
  613. 19,
  614. },
  615. {
  616. 2,
  617. 44,
  618. 20,
  619. },
  620. },
  621. 0,
  622. },
  623. {
  624. 10,
  625. Highest,
  626. dataEncoderType10To26,
  627. []block{
  628. {
  629. 6,
  630. 43,
  631. 15,
  632. },
  633. {
  634. 2,
  635. 44,
  636. 16,
  637. },
  638. },
  639. 0,
  640. },
  641. {
  642. 11,
  643. Low,
  644. dataEncoderType10To26,
  645. []block{
  646. {
  647. 4,
  648. 101,
  649. 81,
  650. },
  651. },
  652. 0,
  653. },
  654. {
  655. 11,
  656. Medium,
  657. dataEncoderType10To26,
  658. []block{
  659. {
  660. 1,
  661. 80,
  662. 50,
  663. },
  664. {
  665. 4,
  666. 81,
  667. 51,
  668. },
  669. },
  670. 0,
  671. },
  672. {
  673. 11,
  674. High,
  675. dataEncoderType10To26,
  676. []block{
  677. {
  678. 4,
  679. 50,
  680. 22,
  681. },
  682. {
  683. 4,
  684. 51,
  685. 23,
  686. },
  687. },
  688. 0,
  689. },
  690. {
  691. 11,
  692. Highest,
  693. dataEncoderType10To26,
  694. []block{
  695. {
  696. 3,
  697. 36,
  698. 12,
  699. },
  700. {
  701. 8,
  702. 37,
  703. 13,
  704. },
  705. },
  706. 0,
  707. },
  708. {
  709. 12,
  710. Low,
  711. dataEncoderType10To26,
  712. []block{
  713. {
  714. 2,
  715. 116,
  716. 92,
  717. },
  718. {
  719. 2,
  720. 117,
  721. 93,
  722. },
  723. },
  724. 0,
  725. },
  726. {
  727. 12,
  728. Medium,
  729. dataEncoderType10To26,
  730. []block{
  731. {
  732. 6,
  733. 58,
  734. 36,
  735. },
  736. {
  737. 2,
  738. 59,
  739. 37,
  740. },
  741. },
  742. 0,
  743. },
  744. {
  745. 12,
  746. High,
  747. dataEncoderType10To26,
  748. []block{
  749. {
  750. 4,
  751. 46,
  752. 20,
  753. },
  754. {
  755. 6,
  756. 47,
  757. 21,
  758. },
  759. },
  760. 0,
  761. },
  762. {
  763. 12,
  764. Highest,
  765. dataEncoderType10To26,
  766. []block{
  767. {
  768. 7,
  769. 42,
  770. 14,
  771. },
  772. {
  773. 4,
  774. 43,
  775. 15,
  776. },
  777. },
  778. 0,
  779. },
  780. {
  781. 13,
  782. Low,
  783. dataEncoderType10To26,
  784. []block{
  785. {
  786. 4,
  787. 133,
  788. 107,
  789. },
  790. },
  791. 0,
  792. },
  793. {
  794. 13,
  795. Medium,
  796. dataEncoderType10To26,
  797. []block{
  798. {
  799. 8,
  800. 59,
  801. 37,
  802. },
  803. {
  804. 1,
  805. 60,
  806. 38,
  807. },
  808. },
  809. 0,
  810. },
  811. {
  812. 13,
  813. High,
  814. dataEncoderType10To26,
  815. []block{
  816. {
  817. 8,
  818. 44,
  819. 20,
  820. },
  821. {
  822. 4,
  823. 45,
  824. 21,
  825. },
  826. },
  827. 0,
  828. },
  829. {
  830. 13,
  831. Highest,
  832. dataEncoderType10To26,
  833. []block{
  834. {
  835. 12,
  836. 33,
  837. 11,
  838. },
  839. {
  840. 4,
  841. 34,
  842. 12,
  843. },
  844. },
  845. 0,
  846. },
  847. {
  848. 14,
  849. Low,
  850. dataEncoderType10To26,
  851. []block{
  852. {
  853. 3,
  854. 145,
  855. 115,
  856. },
  857. {
  858. 1,
  859. 146,
  860. 116,
  861. },
  862. },
  863. 3,
  864. },
  865. {
  866. 14,
  867. Medium,
  868. dataEncoderType10To26,
  869. []block{
  870. {
  871. 4,
  872. 64,
  873. 40,
  874. },
  875. {
  876. 5,
  877. 65,
  878. 41,
  879. },
  880. },
  881. 3,
  882. },
  883. {
  884. 14,
  885. High,
  886. dataEncoderType10To26,
  887. []block{
  888. {
  889. 11,
  890. 36,
  891. 16,
  892. },
  893. {
  894. 5,
  895. 37,
  896. 17,
  897. },
  898. },
  899. 3,
  900. },
  901. {
  902. 14,
  903. Highest,
  904. dataEncoderType10To26,
  905. []block{
  906. {
  907. 11,
  908. 36,
  909. 12,
  910. },
  911. {
  912. 5,
  913. 37,
  914. 13,
  915. },
  916. },
  917. 3,
  918. },
  919. {
  920. 15,
  921. Low,
  922. dataEncoderType10To26,
  923. []block{
  924. {
  925. 5,
  926. 109,
  927. 87,
  928. },
  929. {
  930. 1,
  931. 110,
  932. 88,
  933. },
  934. },
  935. 3,
  936. },
  937. {
  938. 15,
  939. Medium,
  940. dataEncoderType10To26,
  941. []block{
  942. {
  943. 5,
  944. 65,
  945. 41,
  946. },
  947. {
  948. 5,
  949. 66,
  950. 42,
  951. },
  952. },
  953. 3,
  954. },
  955. {
  956. 15,
  957. High,
  958. dataEncoderType10To26,
  959. []block{
  960. {
  961. 5,
  962. 54,
  963. 24,
  964. },
  965. {
  966. 7,
  967. 55,
  968. 25,
  969. },
  970. },
  971. 3,
  972. },
  973. {
  974. 15,
  975. Highest,
  976. dataEncoderType10To26,
  977. []block{
  978. {
  979. 11,
  980. 36,
  981. 12,
  982. },
  983. {
  984. 7,
  985. 37,
  986. 13,
  987. },
  988. },
  989. 3,
  990. },
  991. {
  992. 16,
  993. Low,
  994. dataEncoderType10To26,
  995. []block{
  996. {
  997. 5,
  998. 122,
  999. 98,
  1000. },
  1001. {
  1002. 1,
  1003. 123,
  1004. 99,
  1005. },
  1006. },
  1007. 3,
  1008. },
  1009. {
  1010. 16,
  1011. Medium,
  1012. dataEncoderType10To26,
  1013. []block{
  1014. {
  1015. 7,
  1016. 73,
  1017. 45,
  1018. },
  1019. {
  1020. 3,
  1021. 74,
  1022. 46,
  1023. },
  1024. },
  1025. 3,
  1026. },
  1027. {
  1028. 16,
  1029. High,
  1030. dataEncoderType10To26,
  1031. []block{
  1032. {
  1033. 15,
  1034. 43,
  1035. 19,
  1036. },
  1037. {
  1038. 2,
  1039. 44,
  1040. 20,
  1041. },
  1042. },
  1043. 3,
  1044. },
  1045. {
  1046. 16,
  1047. Highest,
  1048. dataEncoderType10To26,
  1049. []block{
  1050. {
  1051. 3,
  1052. 45,
  1053. 15,
  1054. },
  1055. {
  1056. 13,
  1057. 46,
  1058. 16,
  1059. },
  1060. },
  1061. 3,
  1062. },
  1063. {
  1064. 17,
  1065. Low,
  1066. dataEncoderType10To26,
  1067. []block{
  1068. {
  1069. 1,
  1070. 135,
  1071. 107,
  1072. },
  1073. {
  1074. 5,
  1075. 136,
  1076. 108,
  1077. },
  1078. },
  1079. 3,
  1080. },
  1081. {
  1082. 17,
  1083. Medium,
  1084. dataEncoderType10To26,
  1085. []block{
  1086. {
  1087. 10,
  1088. 74,
  1089. 46,
  1090. },
  1091. {
  1092. 1,
  1093. 75,
  1094. 47,
  1095. },
  1096. },
  1097. 3,
  1098. },
  1099. {
  1100. 17,
  1101. High,
  1102. dataEncoderType10To26,
  1103. []block{
  1104. {
  1105. 1,
  1106. 50,
  1107. 22,
  1108. },
  1109. {
  1110. 15,
  1111. 51,
  1112. 23,
  1113. },
  1114. },
  1115. 3,
  1116. },
  1117. {
  1118. 17,
  1119. Highest,
  1120. dataEncoderType10To26,
  1121. []block{
  1122. {
  1123. 2,
  1124. 42,
  1125. 14,
  1126. },
  1127. {
  1128. 17,
  1129. 43,
  1130. 15,
  1131. },
  1132. },
  1133. 3,
  1134. },
  1135. {
  1136. 18,
  1137. Low,
  1138. dataEncoderType10To26,
  1139. []block{
  1140. {
  1141. 5,
  1142. 150,
  1143. 120,
  1144. },
  1145. {
  1146. 1,
  1147. 151,
  1148. 121,
  1149. },
  1150. },
  1151. 3,
  1152. },
  1153. {
  1154. 18,
  1155. Medium,
  1156. dataEncoderType10To26,
  1157. []block{
  1158. {
  1159. 9,
  1160. 69,
  1161. 43,
  1162. },
  1163. {
  1164. 4,
  1165. 70,
  1166. 44,
  1167. },
  1168. },
  1169. 3,
  1170. },
  1171. {
  1172. 18,
  1173. High,
  1174. dataEncoderType10To26,
  1175. []block{
  1176. {
  1177. 17,
  1178. 50,
  1179. 22,
  1180. },
  1181. {
  1182. 1,
  1183. 51,
  1184. 23,
  1185. },
  1186. },
  1187. 3,
  1188. },
  1189. {
  1190. 18,
  1191. Highest,
  1192. dataEncoderType10To26,
  1193. []block{
  1194. {
  1195. 2,
  1196. 42,
  1197. 14,
  1198. },
  1199. {
  1200. 19,
  1201. 43,
  1202. 15,
  1203. },
  1204. },
  1205. 3,
  1206. },
  1207. {
  1208. 19,
  1209. Low,
  1210. dataEncoderType10To26,
  1211. []block{
  1212. {
  1213. 3,
  1214. 141,
  1215. 113,
  1216. },
  1217. {
  1218. 4,
  1219. 142,
  1220. 114,
  1221. },
  1222. },
  1223. 3,
  1224. },
  1225. {
  1226. 19,
  1227. Medium,
  1228. dataEncoderType10To26,
  1229. []block{
  1230. {
  1231. 3,
  1232. 70,
  1233. 44,
  1234. },
  1235. {
  1236. 11,
  1237. 71,
  1238. 45,
  1239. },
  1240. },
  1241. 3,
  1242. },
  1243. {
  1244. 19,
  1245. High,
  1246. dataEncoderType10To26,
  1247. []block{
  1248. {
  1249. 17,
  1250. 47,
  1251. 21,
  1252. },
  1253. {
  1254. 4,
  1255. 48,
  1256. 22,
  1257. },
  1258. },
  1259. 3,
  1260. },
  1261. {
  1262. 19,
  1263. Highest,
  1264. dataEncoderType10To26,
  1265. []block{
  1266. {
  1267. 9,
  1268. 39,
  1269. 13,
  1270. },
  1271. {
  1272. 16,
  1273. 40,
  1274. 14,
  1275. },
  1276. },
  1277. 3,
  1278. },
  1279. {
  1280. 20,
  1281. Low,
  1282. dataEncoderType10To26,
  1283. []block{
  1284. {
  1285. 3,
  1286. 135,
  1287. 107,
  1288. },
  1289. {
  1290. 5,
  1291. 136,
  1292. 108,
  1293. },
  1294. },
  1295. 3,
  1296. },
  1297. {
  1298. 20,
  1299. Medium,
  1300. dataEncoderType10To26,
  1301. []block{
  1302. {
  1303. 3,
  1304. 67,
  1305. 41,
  1306. },
  1307. {
  1308. 13,
  1309. 68,
  1310. 42,
  1311. },
  1312. },
  1313. 3,
  1314. },
  1315. {
  1316. 20,
  1317. High,
  1318. dataEncoderType10To26,
  1319. []block{
  1320. {
  1321. 15,
  1322. 54,
  1323. 24,
  1324. },
  1325. {
  1326. 5,
  1327. 55,
  1328. 25,
  1329. },
  1330. },
  1331. 3,
  1332. },
  1333. {
  1334. 20,
  1335. Highest,
  1336. dataEncoderType10To26,
  1337. []block{
  1338. {
  1339. 15,
  1340. 43,
  1341. 15,
  1342. },
  1343. {
  1344. 10,
  1345. 44,
  1346. 16,
  1347. },
  1348. },
  1349. 3,
  1350. },
  1351. {
  1352. 21,
  1353. Low,
  1354. dataEncoderType10To26,
  1355. []block{
  1356. {
  1357. 4,
  1358. 144,
  1359. 116,
  1360. },
  1361. {
  1362. 4,
  1363. 145,
  1364. 117,
  1365. },
  1366. },
  1367. 4,
  1368. },
  1369. {
  1370. 21,
  1371. Medium,
  1372. dataEncoderType10To26,
  1373. []block{
  1374. {
  1375. 17,
  1376. 68,
  1377. 42,
  1378. },
  1379. },
  1380. 4,
  1381. },
  1382. {
  1383. 21,
  1384. High,
  1385. dataEncoderType10To26,
  1386. []block{
  1387. {
  1388. 17,
  1389. 50,
  1390. 22,
  1391. },
  1392. {
  1393. 6,
  1394. 51,
  1395. 23,
  1396. },
  1397. },
  1398. 4,
  1399. },
  1400. {
  1401. 21,
  1402. Highest,
  1403. dataEncoderType10To26,
  1404. []block{
  1405. {
  1406. 19,
  1407. 46,
  1408. 16,
  1409. },
  1410. {
  1411. 6,
  1412. 47,
  1413. 17,
  1414. },
  1415. },
  1416. 4,
  1417. },
  1418. {
  1419. 22,
  1420. Low,
  1421. dataEncoderType10To26,
  1422. []block{
  1423. {
  1424. 2,
  1425. 139,
  1426. 111,
  1427. },
  1428. {
  1429. 7,
  1430. 140,
  1431. 112,
  1432. },
  1433. },
  1434. 4,
  1435. },
  1436. {
  1437. 22,
  1438. Medium,
  1439. dataEncoderType10To26,
  1440. []block{
  1441. {
  1442. 17,
  1443. 74,
  1444. 46,
  1445. },
  1446. },
  1447. 4,
  1448. },
  1449. {
  1450. 22,
  1451. High,
  1452. dataEncoderType10To26,
  1453. []block{
  1454. {
  1455. 7,
  1456. 54,
  1457. 24,
  1458. },
  1459. {
  1460. 16,
  1461. 55,
  1462. 25,
  1463. },
  1464. },
  1465. 4,
  1466. },
  1467. {
  1468. 22,
  1469. Highest,
  1470. dataEncoderType10To26,
  1471. []block{
  1472. {
  1473. 34,
  1474. 37,
  1475. 13,
  1476. },
  1477. },
  1478. 4,
  1479. },
  1480. {
  1481. 23,
  1482. Low,
  1483. dataEncoderType10To26,
  1484. []block{
  1485. {
  1486. 4,
  1487. 151,
  1488. 121,
  1489. },
  1490. {
  1491. 5,
  1492. 152,
  1493. 122,
  1494. },
  1495. },
  1496. 4,
  1497. },
  1498. {
  1499. 23,
  1500. Medium,
  1501. dataEncoderType10To26,
  1502. []block{
  1503. {
  1504. 4,
  1505. 75,
  1506. 47,
  1507. },
  1508. {
  1509. 14,
  1510. 76,
  1511. 48,
  1512. },
  1513. },
  1514. 4,
  1515. },
  1516. {
  1517. 23,
  1518. High,
  1519. dataEncoderType10To26,
  1520. []block{
  1521. {
  1522. 11,
  1523. 54,
  1524. 24,
  1525. },
  1526. {
  1527. 14,
  1528. 55,
  1529. 25,
  1530. },
  1531. },
  1532. 4,
  1533. },
  1534. {
  1535. 23,
  1536. Highest,
  1537. dataEncoderType10To26,
  1538. []block{
  1539. {
  1540. 16,
  1541. 45,
  1542. 15,
  1543. },
  1544. {
  1545. 14,
  1546. 46,
  1547. 16,
  1548. },
  1549. },
  1550. 4,
  1551. },
  1552. {
  1553. 24,
  1554. Low,
  1555. dataEncoderType10To26,
  1556. []block{
  1557. {
  1558. 6,
  1559. 147,
  1560. 117,
  1561. },
  1562. {
  1563. 4,
  1564. 148,
  1565. 118,
  1566. },
  1567. },
  1568. 4,
  1569. },
  1570. {
  1571. 24,
  1572. Medium,
  1573. dataEncoderType10To26,
  1574. []block{
  1575. {
  1576. 6,
  1577. 73,
  1578. 45,
  1579. },
  1580. {
  1581. 14,
  1582. 74,
  1583. 46,
  1584. },
  1585. },
  1586. 4,
  1587. },
  1588. {
  1589. 24,
  1590. High,
  1591. dataEncoderType10To26,
  1592. []block{
  1593. {
  1594. 11,
  1595. 54,
  1596. 24,
  1597. },
  1598. {
  1599. 16,
  1600. 55,
  1601. 25,
  1602. },
  1603. },
  1604. 4,
  1605. },
  1606. {
  1607. 24,
  1608. Highest,
  1609. dataEncoderType10To26,
  1610. []block{
  1611. {
  1612. 30,
  1613. 46,
  1614. 16,
  1615. },
  1616. {
  1617. 2,
  1618. 47,
  1619. 17,
  1620. },
  1621. },
  1622. 4,
  1623. },
  1624. {
  1625. 25,
  1626. Low,
  1627. dataEncoderType10To26,
  1628. []block{
  1629. {
  1630. 8,
  1631. 132,
  1632. 106,
  1633. },
  1634. {
  1635. 4,
  1636. 133,
  1637. 107,
  1638. },
  1639. },
  1640. 4,
  1641. },
  1642. {
  1643. 25,
  1644. Medium,
  1645. dataEncoderType10To26,
  1646. []block{
  1647. {
  1648. 8,
  1649. 75,
  1650. 47,
  1651. },
  1652. {
  1653. 13,
  1654. 76,
  1655. 48,
  1656. },
  1657. },
  1658. 4,
  1659. },
  1660. {
  1661. 25,
  1662. High,
  1663. dataEncoderType10To26,
  1664. []block{
  1665. {
  1666. 7,
  1667. 54,
  1668. 24,
  1669. },
  1670. {
  1671. 22,
  1672. 55,
  1673. 25,
  1674. },
  1675. },
  1676. 4,
  1677. },
  1678. {
  1679. 25,
  1680. Highest,
  1681. dataEncoderType10To26,
  1682. []block{
  1683. {
  1684. 22,
  1685. 45,
  1686. 15,
  1687. },
  1688. {
  1689. 13,
  1690. 46,
  1691. 16,
  1692. },
  1693. },
  1694. 4,
  1695. },
  1696. {
  1697. 26,
  1698. Low,
  1699. dataEncoderType10To26,
  1700. []block{
  1701. {
  1702. 10,
  1703. 142,
  1704. 114,
  1705. },
  1706. {
  1707. 2,
  1708. 143,
  1709. 115,
  1710. },
  1711. },
  1712. 4,
  1713. },
  1714. {
  1715. 26,
  1716. Medium,
  1717. dataEncoderType10To26,
  1718. []block{
  1719. {
  1720. 19,
  1721. 74,
  1722. 46,
  1723. },
  1724. {
  1725. 4,
  1726. 75,
  1727. 47,
  1728. },
  1729. },
  1730. 4,
  1731. },
  1732. {
  1733. 26,
  1734. High,
  1735. dataEncoderType10To26,
  1736. []block{
  1737. {
  1738. 28,
  1739. 50,
  1740. 22,
  1741. },
  1742. {
  1743. 6,
  1744. 51,
  1745. 23,
  1746. },
  1747. },
  1748. 4,
  1749. },
  1750. {
  1751. 26,
  1752. Highest,
  1753. dataEncoderType10To26,
  1754. []block{
  1755. {
  1756. 33,
  1757. 46,
  1758. 16,
  1759. },
  1760. {
  1761. 4,
  1762. 47,
  1763. 17,
  1764. },
  1765. },
  1766. 4,
  1767. },
  1768. {
  1769. 27,
  1770. Low,
  1771. dataEncoderType27To40,
  1772. []block{
  1773. {
  1774. 8,
  1775. 152,
  1776. 122,
  1777. },
  1778. {
  1779. 4,
  1780. 153,
  1781. 123,
  1782. },
  1783. },
  1784. 4,
  1785. },
  1786. {
  1787. 27,
  1788. Medium,
  1789. dataEncoderType27To40,
  1790. []block{
  1791. {
  1792. 22,
  1793. 73,
  1794. 45,
  1795. },
  1796. {
  1797. 3,
  1798. 74,
  1799. 46,
  1800. },
  1801. },
  1802. 4,
  1803. },
  1804. {
  1805. 27,
  1806. High,
  1807. dataEncoderType27To40,
  1808. []block{
  1809. {
  1810. 8,
  1811. 53,
  1812. 23,
  1813. },
  1814. {
  1815. 26,
  1816. 54,
  1817. 24,
  1818. },
  1819. },
  1820. 4,
  1821. },
  1822. {
  1823. 27,
  1824. Highest,
  1825. dataEncoderType27To40,
  1826. []block{
  1827. {
  1828. 12,
  1829. 45,
  1830. 15,
  1831. },
  1832. {
  1833. 28,
  1834. 46,
  1835. 16,
  1836. },
  1837. },
  1838. 4,
  1839. },
  1840. {
  1841. 28,
  1842. Low,
  1843. dataEncoderType27To40,
  1844. []block{
  1845. {
  1846. 3,
  1847. 147,
  1848. 117,
  1849. },
  1850. {
  1851. 10,
  1852. 148,
  1853. 118,
  1854. },
  1855. },
  1856. 3,
  1857. },
  1858. {
  1859. 28,
  1860. Medium,
  1861. dataEncoderType27To40,
  1862. []block{
  1863. {
  1864. 3,
  1865. 73,
  1866. 45,
  1867. },
  1868. {
  1869. 23,
  1870. 74,
  1871. 46,
  1872. },
  1873. },
  1874. 3,
  1875. },
  1876. {
  1877. 28,
  1878. High,
  1879. dataEncoderType27To40,
  1880. []block{
  1881. {
  1882. 4,
  1883. 54,
  1884. 24,
  1885. },
  1886. {
  1887. 31,
  1888. 55,
  1889. 25,
  1890. },
  1891. },
  1892. 3,
  1893. },
  1894. {
  1895. 28,
  1896. Highest,
  1897. dataEncoderType27To40,
  1898. []block{
  1899. {
  1900. 11,
  1901. 45,
  1902. 15,
  1903. },
  1904. {
  1905. 31,
  1906. 46,
  1907. 16,
  1908. },
  1909. },
  1910. 3,
  1911. },
  1912. {
  1913. 29,
  1914. Low,
  1915. dataEncoderType27To40,
  1916. []block{
  1917. {
  1918. 7,
  1919. 146,
  1920. 116,
  1921. },
  1922. {
  1923. 7,
  1924. 147,
  1925. 117,
  1926. },
  1927. },
  1928. 3,
  1929. },
  1930. {
  1931. 29,
  1932. Medium,
  1933. dataEncoderType27To40,
  1934. []block{
  1935. {
  1936. 21,
  1937. 73,
  1938. 45,
  1939. },
  1940. {
  1941. 7,
  1942. 74,
  1943. 46,
  1944. },
  1945. },
  1946. 3,
  1947. },
  1948. {
  1949. 29,
  1950. High,
  1951. dataEncoderType27To40,
  1952. []block{
  1953. {
  1954. 1,
  1955. 53,
  1956. 23,
  1957. },
  1958. {
  1959. 37,
  1960. 54,
  1961. 24,
  1962. },
  1963. },
  1964. 3,
  1965. },
  1966. {
  1967. 29,
  1968. Highest,
  1969. dataEncoderType27To40,
  1970. []block{
  1971. {
  1972. 19,
  1973. 45,
  1974. 15,
  1975. },
  1976. {
  1977. 26,
  1978. 46,
  1979. 16,
  1980. },
  1981. },
  1982. 3,
  1983. },
  1984. {
  1985. 30,
  1986. Low,
  1987. dataEncoderType27To40,
  1988. []block{
  1989. {
  1990. 5,
  1991. 145,
  1992. 115,
  1993. },
  1994. {
  1995. 10,
  1996. 146,
  1997. 116,
  1998. },
  1999. },
  2000. 3,
  2001. },
  2002. {
  2003. 30,
  2004. Medium,
  2005. dataEncoderType27To40,
  2006. []block{
  2007. {
  2008. 19,
  2009. 75,
  2010. 47,
  2011. },
  2012. {
  2013. 10,
  2014. 76,
  2015. 48,
  2016. },
  2017. },
  2018. 3,
  2019. },
  2020. {
  2021. 30,
  2022. High,
  2023. dataEncoderType27To40,
  2024. []block{
  2025. {
  2026. 15,
  2027. 54,
  2028. 24,
  2029. },
  2030. {
  2031. 25,
  2032. 55,
  2033. 25,
  2034. },
  2035. },
  2036. 3,
  2037. },
  2038. {
  2039. 30,
  2040. Highest,
  2041. dataEncoderType27To40,
  2042. []block{
  2043. {
  2044. 23,
  2045. 45,
  2046. 15,
  2047. },
  2048. {
  2049. 25,
  2050. 46,
  2051. 16,
  2052. },
  2053. },
  2054. 3,
  2055. },
  2056. {
  2057. 31,
  2058. Low,
  2059. dataEncoderType27To40,
  2060. []block{
  2061. {
  2062. 13,
  2063. 145,
  2064. 115,
  2065. },
  2066. {
  2067. 3,
  2068. 146,
  2069. 116,
  2070. },
  2071. },
  2072. 3,
  2073. },
  2074. {
  2075. 31,
  2076. Medium,
  2077. dataEncoderType27To40,
  2078. []block{
  2079. {
  2080. 2,
  2081. 74,
  2082. 46,
  2083. },
  2084. {
  2085. 29,
  2086. 75,
  2087. 47,
  2088. },
  2089. },
  2090. 3,
  2091. },
  2092. {
  2093. 31,
  2094. High,
  2095. dataEncoderType27To40,
  2096. []block{
  2097. {
  2098. 42,
  2099. 54,
  2100. 24,
  2101. },
  2102. {
  2103. 1,
  2104. 55,
  2105. 25,
  2106. },
  2107. },
  2108. 3,
  2109. },
  2110. {
  2111. 31,
  2112. Highest,
  2113. dataEncoderType27To40,
  2114. []block{
  2115. {
  2116. 23,
  2117. 45,
  2118. 15,
  2119. },
  2120. {
  2121. 28,
  2122. 46,
  2123. 16,
  2124. },
  2125. },
  2126. 3,
  2127. },
  2128. {
  2129. 32,
  2130. Low,
  2131. dataEncoderType27To40,
  2132. []block{
  2133. {
  2134. 17,
  2135. 145,
  2136. 115,
  2137. },
  2138. },
  2139. 3,
  2140. },
  2141. {
  2142. 32,
  2143. Medium,
  2144. dataEncoderType27To40,
  2145. []block{
  2146. {
  2147. 10,
  2148. 74,
  2149. 46,
  2150. },
  2151. {
  2152. 23,
  2153. 75,
  2154. 47,
  2155. },
  2156. },
  2157. 3,
  2158. },
  2159. {
  2160. 32,
  2161. High,
  2162. dataEncoderType27To40,
  2163. []block{
  2164. {
  2165. 10,
  2166. 54,
  2167. 24,
  2168. },
  2169. {
  2170. 35,
  2171. 55,
  2172. 25,
  2173. },
  2174. },
  2175. 3,
  2176. },
  2177. {
  2178. 32,
  2179. Highest,
  2180. dataEncoderType27To40,
  2181. []block{
  2182. {
  2183. 19,
  2184. 45,
  2185. 15,
  2186. },
  2187. {
  2188. 35,
  2189. 46,
  2190. 16,
  2191. },
  2192. },
  2193. 3,
  2194. },
  2195. {
  2196. 33,
  2197. Low,
  2198. dataEncoderType27To40,
  2199. []block{
  2200. {
  2201. 17,
  2202. 145,
  2203. 115,
  2204. },
  2205. {
  2206. 1,
  2207. 146,
  2208. 116,
  2209. },
  2210. },
  2211. 3,
  2212. },
  2213. {
  2214. 33,
  2215. Medium,
  2216. dataEncoderType27To40,
  2217. []block{
  2218. {
  2219. 14,
  2220. 74,
  2221. 46,
  2222. },
  2223. {
  2224. 21,
  2225. 75,
  2226. 47,
  2227. },
  2228. },
  2229. 3,
  2230. },
  2231. {
  2232. 33,
  2233. High,
  2234. dataEncoderType27To40,
  2235. []block{
  2236. {
  2237. 29,
  2238. 54,
  2239. 24,
  2240. },
  2241. {
  2242. 19,
  2243. 55,
  2244. 25,
  2245. },
  2246. },
  2247. 3,
  2248. },
  2249. {
  2250. 33,
  2251. Highest,
  2252. dataEncoderType27To40,
  2253. []block{
  2254. {
  2255. 11,
  2256. 45,
  2257. 15,
  2258. },
  2259. {
  2260. 46,
  2261. 46,
  2262. 16,
  2263. },
  2264. },
  2265. 3,
  2266. },
  2267. {
  2268. 34,
  2269. Low,
  2270. dataEncoderType27To40,
  2271. []block{
  2272. {
  2273. 13,
  2274. 145,
  2275. 115,
  2276. },
  2277. {
  2278. 6,
  2279. 146,
  2280. 116,
  2281. },
  2282. },
  2283. 3,
  2284. },
  2285. {
  2286. 34,
  2287. Medium,
  2288. dataEncoderType27To40,
  2289. []block{
  2290. {
  2291. 14,
  2292. 74,
  2293. 46,
  2294. },
  2295. {
  2296. 23,
  2297. 75,
  2298. 47,
  2299. },
  2300. },
  2301. 3,
  2302. },
  2303. {
  2304. 34,
  2305. High,
  2306. dataEncoderType27To40,
  2307. []block{
  2308. {
  2309. 44,
  2310. 54,
  2311. 24,
  2312. },
  2313. {
  2314. 7,
  2315. 55,
  2316. 25,
  2317. },
  2318. },
  2319. 3,
  2320. },
  2321. {
  2322. 34,
  2323. Highest,
  2324. dataEncoderType27To40,
  2325. []block{
  2326. {
  2327. 59,
  2328. 46,
  2329. 16,
  2330. },
  2331. {
  2332. 1,
  2333. 47,
  2334. 17,
  2335. },
  2336. },
  2337. 3,
  2338. },
  2339. {
  2340. 35,
  2341. Low,
  2342. dataEncoderType27To40,
  2343. []block{
  2344. {
  2345. 12,
  2346. 151,
  2347. 121,
  2348. },
  2349. {
  2350. 7,
  2351. 152,
  2352. 122,
  2353. },
  2354. },
  2355. 0,
  2356. },
  2357. {
  2358. 35,
  2359. Medium,
  2360. dataEncoderType27To40,
  2361. []block{
  2362. {
  2363. 12,
  2364. 75,
  2365. 47,
  2366. },
  2367. {
  2368. 26,
  2369. 76,
  2370. 48,
  2371. },
  2372. },
  2373. 0,
  2374. },
  2375. {
  2376. 35,
  2377. High,
  2378. dataEncoderType27To40,
  2379. []block{
  2380. {
  2381. 39,
  2382. 54,
  2383. 24,
  2384. },
  2385. {
  2386. 14,
  2387. 55,
  2388. 25,
  2389. },
  2390. },
  2391. 0,
  2392. },
  2393. {
  2394. 35,
  2395. Highest,
  2396. dataEncoderType27To40,
  2397. []block{
  2398. {
  2399. 22,
  2400. 45,
  2401. 15,
  2402. },
  2403. {
  2404. 41,
  2405. 46,
  2406. 16,
  2407. },
  2408. },
  2409. 0,
  2410. },
  2411. {
  2412. 36,
  2413. Low,
  2414. dataEncoderType27To40,
  2415. []block{
  2416. {
  2417. 6,
  2418. 151,
  2419. 121,
  2420. },
  2421. {
  2422. 14,
  2423. 152,
  2424. 122,
  2425. },
  2426. },
  2427. 0,
  2428. },
  2429. {
  2430. 36,
  2431. Medium,
  2432. dataEncoderType27To40,
  2433. []block{
  2434. {
  2435. 6,
  2436. 75,
  2437. 47,
  2438. },
  2439. {
  2440. 34,
  2441. 76,
  2442. 48,
  2443. },
  2444. },
  2445. 0,
  2446. },
  2447. {
  2448. 36,
  2449. High,
  2450. dataEncoderType27To40,
  2451. []block{
  2452. {
  2453. 46,
  2454. 54,
  2455. 24,
  2456. },
  2457. {
  2458. 10,
  2459. 55,
  2460. 25,
  2461. },
  2462. },
  2463. 0,
  2464. },
  2465. {
  2466. 36,
  2467. Highest,
  2468. dataEncoderType27To40,
  2469. []block{
  2470. {
  2471. 2,
  2472. 45,
  2473. 15,
  2474. },
  2475. {
  2476. 64,
  2477. 46,
  2478. 16,
  2479. },
  2480. },
  2481. 0,
  2482. },
  2483. {
  2484. 37,
  2485. Low,
  2486. dataEncoderType27To40,
  2487. []block{
  2488. {
  2489. 17,
  2490. 152,
  2491. 122,
  2492. },
  2493. {
  2494. 4,
  2495. 153,
  2496. 123,
  2497. },
  2498. },
  2499. 0,
  2500. },
  2501. {
  2502. 37,
  2503. Medium,
  2504. dataEncoderType27To40,
  2505. []block{
  2506. {
  2507. 29,
  2508. 74,
  2509. 46,
  2510. },
  2511. {
  2512. 14,
  2513. 75,
  2514. 47,
  2515. },
  2516. },
  2517. 0,
  2518. },
  2519. {
  2520. 37,
  2521. High,
  2522. dataEncoderType27To40,
  2523. []block{
  2524. {
  2525. 49,
  2526. 54,
  2527. 24,
  2528. },
  2529. {
  2530. 10,
  2531. 55,
  2532. 25,
  2533. },
  2534. },
  2535. 0,
  2536. },
  2537. {
  2538. 37,
  2539. Highest,
  2540. dataEncoderType27To40,
  2541. []block{
  2542. {
  2543. 24,
  2544. 45,
  2545. 15,
  2546. },
  2547. {
  2548. 46,
  2549. 46,
  2550. 16,
  2551. },
  2552. },
  2553. 0,
  2554. },
  2555. {
  2556. 38,
  2557. Low,
  2558. dataEncoderType27To40,
  2559. []block{
  2560. {
  2561. 4,
  2562. 152,
  2563. 122,
  2564. },
  2565. {
  2566. 18,
  2567. 153,
  2568. 123,
  2569. },
  2570. },
  2571. 0,
  2572. },
  2573. {
  2574. 38,
  2575. Medium,
  2576. dataEncoderType27To40,
  2577. []block{
  2578. {
  2579. 13,
  2580. 74,
  2581. 46,
  2582. },
  2583. {
  2584. 32,
  2585. 75,
  2586. 47,
  2587. },
  2588. },
  2589. 0,
  2590. },
  2591. {
  2592. 38,
  2593. High,
  2594. dataEncoderType27To40,
  2595. []block{
  2596. {
  2597. 48,
  2598. 54,
  2599. 24,
  2600. },
  2601. {
  2602. 14,
  2603. 55,
  2604. 25,
  2605. },
  2606. },
  2607. 0,
  2608. },
  2609. {
  2610. 38,
  2611. Highest,
  2612. dataEncoderType27To40,
  2613. []block{
  2614. {
  2615. 42,
  2616. 45,
  2617. 15,
  2618. },
  2619. {
  2620. 32,
  2621. 46,
  2622. 16,
  2623. },
  2624. },
  2625. 0,
  2626. },
  2627. {
  2628. 39,
  2629. Low,
  2630. dataEncoderType27To40,
  2631. []block{
  2632. {
  2633. 20,
  2634. 147,
  2635. 117,
  2636. },
  2637. {
  2638. 4,
  2639. 148,
  2640. 118,
  2641. },
  2642. },
  2643. 0,
  2644. },
  2645. {
  2646. 39,
  2647. Medium,
  2648. dataEncoderType27To40,
  2649. []block{
  2650. {
  2651. 40,
  2652. 75,
  2653. 47,
  2654. },
  2655. {
  2656. 7,
  2657. 76,
  2658. 48,
  2659. },
  2660. },
  2661. 0,
  2662. },
  2663. {
  2664. 39,
  2665. High,
  2666. dataEncoderType27To40,
  2667. []block{
  2668. {
  2669. 43,
  2670. 54,
  2671. 24,
  2672. },
  2673. {
  2674. 22,
  2675. 55,
  2676. 25,
  2677. },
  2678. },
  2679. 0,
  2680. },
  2681. {
  2682. 39,
  2683. Highest,
  2684. dataEncoderType27To40,
  2685. []block{
  2686. {
  2687. 10,
  2688. 45,
  2689. 15,
  2690. },
  2691. {
  2692. 67,
  2693. 46,
  2694. 16,
  2695. },
  2696. },
  2697. 0,
  2698. },
  2699. {
  2700. 40,
  2701. Low,
  2702. dataEncoderType27To40,
  2703. []block{
  2704. {
  2705. 19,
  2706. 148,
  2707. 118,
  2708. },
  2709. {
  2710. 6,
  2711. 149,
  2712. 119,
  2713. },
  2714. },
  2715. 0,
  2716. },
  2717. {
  2718. 40,
  2719. Medium,
  2720. dataEncoderType27To40,
  2721. []block{
  2722. {
  2723. 18,
  2724. 75,
  2725. 47,
  2726. },
  2727. {
  2728. 31,
  2729. 76,
  2730. 48,
  2731. },
  2732. },
  2733. 0,
  2734. },
  2735. {
  2736. 40,
  2737. High,
  2738. dataEncoderType27To40,
  2739. []block{
  2740. {
  2741. 34,
  2742. 54,
  2743. 24,
  2744. },
  2745. {
  2746. 34,
  2747. 55,
  2748. 25,
  2749. },
  2750. },
  2751. 0,
  2752. },
  2753. {
  2754. 40,
  2755. Highest,
  2756. dataEncoderType27To40,
  2757. []block{
  2758. {
  2759. 20,
  2760. 45,
  2761. 15,
  2762. },
  2763. {
  2764. 61,
  2765. 46,
  2766. 16,
  2767. },
  2768. },
  2769. 0,
  2770. },
  2771. }
  2772. )
  2773. var (
  2774. // Each QR Code contains a 15-bit Format Information value. The 15 bits
  2775. // consist of 5 data bits concatenated with 10 error correction bits.
  2776. //
  2777. // The 5 data bits consist of:
  2778. // - 2 bits for the error correction level (L=01, M=00, G=11, H=10).
  2779. // - 3 bits for the data mask pattern identifier.
  2780. //
  2781. // formatBitSequence is a mapping from the 5 data bits to the completed 15-bit
  2782. // Format Information value.
  2783. //
  2784. // For example, a QR Code using error correction level L, and data mask
  2785. // pattern identifier 001:
  2786. //
  2787. // 01 | 001 = 01001 = 0x9
  2788. // formatBitSequence[0x9].qrCode = 0x72f3 = 111001011110011
  2789. formatBitSequence = []struct {
  2790. regular uint32
  2791. micro uint32
  2792. }{
  2793. {0x5412, 0x4445},
  2794. {0x5125, 0x4172},
  2795. {0x5e7c, 0x4e2b},
  2796. {0x5b4b, 0x4b1c},
  2797. {0x45f9, 0x55ae},
  2798. {0x40ce, 0x5099},
  2799. {0x4f97, 0x5fc0},
  2800. {0x4aa0, 0x5af7},
  2801. {0x77c4, 0x6793},
  2802. {0x72f3, 0x62a4},
  2803. {0x7daa, 0x6dfd},
  2804. {0x789d, 0x68ca},
  2805. {0x662f, 0x7678},
  2806. {0x6318, 0x734f},
  2807. {0x6c41, 0x7c16},
  2808. {0x6976, 0x7921},
  2809. {0x1689, 0x06de},
  2810. {0x13be, 0x03e9},
  2811. {0x1ce7, 0x0cb0},
  2812. {0x19d0, 0x0987},
  2813. {0x0762, 0x1735},
  2814. {0x0255, 0x1202},
  2815. {0x0d0c, 0x1d5b},
  2816. {0x083b, 0x186c},
  2817. {0x355f, 0x2508},
  2818. {0x3068, 0x203f},
  2819. {0x3f31, 0x2f66},
  2820. {0x3a06, 0x2a51},
  2821. {0x24b4, 0x34e3},
  2822. {0x2183, 0x31d4},
  2823. {0x2eda, 0x3e8d},
  2824. {0x2bed, 0x3bba},
  2825. }
  2826. // QR Codes version 7 and higher contain an 18-bit Version Information value,
  2827. // consisting of a 6 data bits and 12 error correction bits.
  2828. //
  2829. // versionBitSequence is a mapping from QR Code version to the completed
  2830. // 18-bit Version Information value.
  2831. //
  2832. // For example, a QR code of version 7:
  2833. // versionBitSequence[0x7] = 0x07c94 = 000111110010010100
  2834. versionBitSequence = []uint32{
  2835. 0x00000,
  2836. 0x00000,
  2837. 0x00000,
  2838. 0x00000,
  2839. 0x00000,
  2840. 0x00000,
  2841. 0x00000,
  2842. 0x07c94,
  2843. 0x085bc,
  2844. 0x09a99,
  2845. 0x0a4d3,
  2846. 0x0bbf6,
  2847. 0x0c762,
  2848. 0x0d847,
  2849. 0x0e60d,
  2850. 0x0f928,
  2851. 0x10b78,
  2852. 0x1145d,
  2853. 0x12a17,
  2854. 0x13532,
  2855. 0x149a6,
  2856. 0x15683,
  2857. 0x168c9,
  2858. 0x177ec,
  2859. 0x18ec4,
  2860. 0x191e1,
  2861. 0x1afab,
  2862. 0x1b08e,
  2863. 0x1cc1a,
  2864. 0x1d33f,
  2865. 0x1ed75,
  2866. 0x1f250,
  2867. 0x209d5,
  2868. 0x216f0,
  2869. 0x228ba,
  2870. 0x2379f,
  2871. 0x24b0b,
  2872. 0x2542e,
  2873. 0x26a64,
  2874. 0x27541,
  2875. 0x28c69,
  2876. }
  2877. )
  2878. const (
  2879. formatInfoLengthBits = 15
  2880. versionInfoLengthBits = 18
  2881. )
  2882. // formatInfo returns the 15-bit Format Information value for a QR
  2883. // code.
  2884. func (v qrCodeVersion) formatInfo(maskPattern int) *bitset.Bitset {
  2885. formatID := 0
  2886. switch v.level {
  2887. case Low:
  2888. formatID = 0x08 // 0b01000
  2889. case Medium:
  2890. formatID = 0x00 // 0b00000
  2891. case High:
  2892. formatID = 0x18 // 0b11000
  2893. case Highest:
  2894. formatID = 0x10 // 0b10000
  2895. default:
  2896. log.Panicf("Invalid level %d", v.level)
  2897. }
  2898. if maskPattern < 0 || maskPattern > 7 {
  2899. log.Panicf("Invalid maskPattern %d", maskPattern)
  2900. }
  2901. formatID |= maskPattern & 0x7
  2902. result := bitset.New()
  2903. result.AppendUint32(formatBitSequence[formatID].regular, formatInfoLengthBits)
  2904. return result
  2905. }
  2906. // versionInfo returns the 18-bit Version Information value for a QR Code.
  2907. //
  2908. // Version Information is applicable only to QR Codes versions 7-40 inclusive.
  2909. // nil is returned if Version Information is not required.
  2910. func (v qrCodeVersion) versionInfo() *bitset.Bitset {
  2911. if v.version < 7 {
  2912. return nil
  2913. }
  2914. result := bitset.New()
  2915. result.AppendUint32(versionBitSequence[v.version], 18)
  2916. return result
  2917. }
  2918. // numDataBits returns the data capacity in bits.
  2919. func (v qrCodeVersion) numDataBits() int {
  2920. numDataBits := 0
  2921. for _, b := range v.block {
  2922. numDataBits += 8 * b.numBlocks * b.numDataCodewords // 8 bits in a byte
  2923. }
  2924. return numDataBits
  2925. }
  2926. // chooseQRCodeVersion chooses the most suitable QR Code version for a stated
  2927. // data length in bits, the error recovery level required, and the data encoder
  2928. // used.
  2929. //
  2930. // The chosen QR Code version is the smallest version able to fit numDataBits
  2931. // and the optional terminator bits required by the specified encoder.
  2932. //
  2933. // On success the chosen QR Code version is returned.
  2934. func chooseQRCodeVersion(level RecoveryLevel, encoder *dataEncoder, numDataBits int) *qrCodeVersion {
  2935. var chosenVersion *qrCodeVersion
  2936. for _, v := range versions {
  2937. if v.level != level {
  2938. continue
  2939. } else if v.version < encoder.minVersion {
  2940. continue
  2941. } else if v.version > encoder.maxVersion {
  2942. break
  2943. }
  2944. numFreeBits := v.numDataBits() - numDataBits
  2945. if numFreeBits >= 0 {
  2946. chosenVersion = &v
  2947. break
  2948. }
  2949. }
  2950. return chosenVersion
  2951. }
  2952. func (v qrCodeVersion) numTerminatorBitsRequired(numDataBits int) int {
  2953. numFreeBits := v.numDataBits() - numDataBits
  2954. var numTerminatorBits int
  2955. switch {
  2956. case numFreeBits >= 4:
  2957. numTerminatorBits = 4
  2958. default:
  2959. numTerminatorBits = numFreeBits
  2960. }
  2961. return numTerminatorBits
  2962. }
  2963. // numBlocks returns the number of blocks.
  2964. func (v qrCodeVersion) numBlocks() int {
  2965. numBlocks := 0
  2966. for _, b := range v.block {
  2967. numBlocks += b.numBlocks
  2968. }
  2969. return numBlocks
  2970. }
  2971. // numBitsToPadToCodeword returns the number of bits required to pad data of
  2972. // length numDataBits upto the nearest codeword size.
  2973. func (v qrCodeVersion) numBitsToPadToCodeword(numDataBits int) int {
  2974. if numDataBits == v.numDataBits() {
  2975. return 0
  2976. }
  2977. return (8 - numDataBits%8) % 8
  2978. }
  2979. // symbolSize returns the size of the QR Code symbol in number of modules (which
  2980. // is both the width and height, since QR codes are square). The QR Code has
  2981. // size symbolSize() x symbolSize() pixels. This does not include the quiet
  2982. // zone.
  2983. func (v qrCodeVersion) symbolSize() int {
  2984. return 21 + (v.version-1)*4
  2985. }
  2986. // quietZoneSize returns the number of pixels of border space on each side of
  2987. // the QR Code. The quiet space assists with decoding.
  2988. func (v qrCodeVersion) quietZoneSize() int {
  2989. return 4
  2990. }
  2991. // getQRCodeVersion returns the QR Code version by version number and recovery
  2992. // level. Returns nil if the requested combination is not defined.
  2993. func getQRCodeVersion(level RecoveryLevel, version int) *qrCodeVersion {
  2994. for _, v := range versions {
  2995. if v.level == level && v.version == version {
  2996. return &v
  2997. }
  2998. }
  2999. return nil
  3000. }