rss.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. /* rss.h - Data tables for Reduced Space Symbology */
  2. /*
  3. libzint - the open source barcode library
  4. Copyright (C) 2007-2024 Robin Stuart <rstuart114@gmail.com>
  5. Redistribution and use in source and binary forms, with or without
  6. modification, are permitted provided that the following conditions
  7. are met:
  8. 1. Redistributions of source code must retain the above copyright
  9. notice, this list of conditions and the following disclaimer.
  10. 2. Redistributions in binary form must reproduce the above copyright
  11. notice, this list of conditions and the following disclaimer in the
  12. documentation and/or other materials provided with the distribution.
  13. 3. Neither the name of the project nor the names of its contributors
  14. may be used to endorse or promote products derived from this software
  15. without specific prior written permission.
  16. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  17. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  20. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  22. OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  23. HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  24. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  25. OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  26. SUCH DAMAGE.
  27. */
  28. /* SPDX-License-Identifier: BSD-3-Clause */
  29. #ifndef Z_RSS_H
  30. #define Z_RSS_H
  31. /* RSS-14 Tables */
  32. static const unsigned short dbar_g_sum_table[9] = {
  33. 0, 161, 961, 2015, 2715, 0, 336, 1036, 1516
  34. };
  35. static const char dbar_t_table[9] = {
  36. 1, 10, 34, 70, 126, 4, 20, 48, 81
  37. };
  38. static const char dbar_modules_odd[9] = {
  39. 12, 10, 8, 6, 4, 5, 7, 9, 11
  40. };
  41. static const char dbar_modules_even[9] = {
  42. 4, 6, 8, 10, 12, 10, 8, 6, 4
  43. };
  44. static const char dbar_widest_odd[9] = {
  45. 8, 6, 4, 3, 1, 2, 4, 6, 8
  46. };
  47. static const char dbar_widest_even[9] = {
  48. 1, 3, 5, 6, 8, 7, 5, 3, 1
  49. };
  50. static const char dbar_finder_pattern[45] = {
  51. 3, 8, 2, 1, 1,
  52. 3, 5, 5, 1, 1,
  53. 3, 3, 7, 1, 1,
  54. 3, 1, 9, 1, 1,
  55. 2, 7, 4, 1, 1,
  56. 2, 5, 6, 1, 1,
  57. 2, 3, 8, 1, 1,
  58. 1, 5, 7, 1, 1,
  59. 1, 3, 9, 1, 1
  60. };
  61. /* Table 5 */
  62. static const char dbar_checksum_weight[32] = {
  63. 1, 3, 9, 27, 2, 6, 18, 54,
  64. 4, 12, 36, 29, 8, 24, 72, 58,
  65. 16, 48, 65, 37, 32, 17, 51, 74,
  66. 64, 34, 23, 69, 49, 68, 46, 59
  67. };
  68. /* RSS Limited Tables */
  69. static const unsigned short dbar_ltd_t_even[7] = {
  70. 28, 728, 6454, 203, 2408, 1, 16632
  71. };
  72. static const char dbar_ltd_modules_odd[7] = {
  73. 17, 13, 9, 15, 11, 19, 7
  74. };
  75. static const char dbar_ltd_modules_even[7] = {
  76. 9, 13, 17, 11, 15, 7, 19
  77. };
  78. static const char dbar_ltd_widest_odd[7] = {
  79. 6, 5, 3, 5, 4, 8, 1
  80. };
  81. static const char dbar_ltd_widest_even[7] = {
  82. 3, 4, 6, 4, 5, 1, 8
  83. };
  84. /* Table 7 */
  85. static const char dbar_ltd_checksum_weight[28] = {
  86. 1, 3, 9, 27, 81, 65, 17, 51, 64, 14, 42, 37, 22, 66,
  87. 20, 60, 2, 6, 18, 54, 73, 41, 34, 13, 39, 28, 84, 74
  88. };
  89. static const char dbar_ltd_finder_pattern[1246] = {
  90. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 1,
  91. 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 1, 1,
  92. 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 1, 1,
  93. 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 3, 2, 1, 1,
  94. 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 3, 1, 1, 1,
  95. 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 3, 1, 1, 1,
  96. 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 3, 2, 1, 1,
  97. 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 3, 1, 1, 1,
  98. 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 3, 1, 1, 1,
  99. 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1,
  100. 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, 2, 1, 1,
  101. 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1,
  102. 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 3, 1, 1, 1,
  103. 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 3, 1, 1, 1,
  104. 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1,
  105. 1, 2, 1, 1, 1, 1, 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 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1,
  173. 2, 1, 1, 1, 1, 1, 1, 2, 1, 2, 2, 1, 1, 1,
  174. 2, 1, 1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1, 1,
  175. 2, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1,
  176. 2, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 1,
  177. 2, 1, 1, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1,
  178. 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 1, 1
  179. };
  180. /* RSS Expanded Tables */
  181. static const unsigned short dbar_exp_g_sum[5] = {
  182. 0, 348, 1388, 2948, 3988
  183. };
  184. static const unsigned char dbar_exp_t_even[5] = {
  185. 4, 20, 52, 104, 204
  186. };
  187. static const char dbar_exp_modules_odd[5] = {
  188. 12, 10, 8, 6, 4
  189. };
  190. static const char dbar_exp_modules_even[5] = {
  191. 5, 7, 9, 11, 13
  192. };
  193. static const char dbar_exp_widest_odd[5] = {
  194. 7, 5, 4, 3, 1
  195. };
  196. static const char dbar_exp_widest_even[5] = {
  197. 2, 4, 5, 6, 8
  198. };
  199. /* Table 14 */
  200. static const unsigned char dbar_exp_checksum_weight[184] = {
  201. 1, 3, 9, 27, 81, 32, 96, 77,
  202. 20, 60, 180, 118, 143, 7, 21, 63,
  203. 189, 145, 13, 39, 117, 140, 209, 205,
  204. 193, 157, 49, 147, 19, 57, 171, 91,
  205. 62, 186, 136, 197, 169, 85, 44, 132,
  206. 185, 133, 188, 142, 4, 12, 36, 108,
  207. 113, 128, 173, 97, 80, 29, 87, 50,
  208. 150, 28, 84, 41, 123, 158, 52, 156,
  209. 46, 138, 203, 187, 139, 206, 196, 166,
  210. 76, 17, 51, 153, 37, 111, 122, 155,
  211. 43, 129, 176, 106, 107, 110, 119, 146,
  212. 16, 48, 144, 10, 30, 90, 59, 177,
  213. 109, 116, 137, 200, 178, 112, 125, 164,
  214. 70, 210, 208, 202, 184, 130, 179, 115,
  215. 134, 191, 151, 31, 93, 68, 204, 190,
  216. 148, 22, 66, 198, 172, 94, 71, 2,
  217. 6, 18, 54, 162, 64, 192, 154, 40,
  218. 120, 149, 25, 75, 14, 42, 126, 167,
  219. 79, 26, 78, 23, 69, 207, 199, 175,
  220. 103, 98, 83, 38, 114, 131, 182, 124,
  221. 161, 61, 183, 127, 170, 88, 53, 159,
  222. 55, 165, 73, 8, 24, 72, 5, 15,
  223. 45, 135, 194, 160, 58, 174, 100, 89
  224. };
  225. /* Table 15 */
  226. static const char dbar_exp_finder_pattern[60] = {
  227. 1, 8, 4, 1, 1,
  228. 1, 1, 4, 8, 1,
  229. 3, 6, 4, 1, 1,
  230. 1, 1, 4, 6, 3,
  231. 3, 4, 6, 1, 1,
  232. 1, 1, 6, 4, 3,
  233. 3, 2, 8, 1, 1,
  234. 1, 1, 8, 2, 3,
  235. 2, 6, 5, 1, 1,
  236. 1, 1, 5, 6, 2,
  237. 2, 2, 9, 1, 1,
  238. 1, 1, 9, 2, 2
  239. };
  240. /* Table 16 */
  241. static const char dbar_exp_finder_sequence[198] = {
  242. 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  243. 1, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0,
  244. 1, 6, 3, 8, 0, 0, 0, 0, 0, 0, 0,
  245. 1, 10, 3, 8, 5, 0, 0, 0, 0, 0, 0,
  246. 1, 10, 3, 8, 7, 12, 0, 0, 0, 0, 0,
  247. 1, 10, 3, 8, 9, 12, 11, 0, 0, 0, 0,
  248. 1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0,
  249. 1, 2, 3, 4, 5, 6, 7, 10, 9, 0, 0,
  250. 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 0,
  251. 1, 2, 3, 4, 5, 8, 7, 10, 9, 12, 11
  252. };
  253. static const char dbar_exp_weight_rows[210] = {
  254. 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  255. 0, 5, 6, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  256. 0, 9, 10, 3, 4, 13, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  257. 0, 17, 18, 3, 4, 13, 14, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  258. 0, 17, 18, 3, 4, 13, 14, 11, 12, 21, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  259. 0, 17, 18, 3, 4, 13, 14, 15, 16, 21, 22, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0,
  260. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 0, 0, 0, 0, 0,
  261. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 17, 18, 15, 16, 0, 0, 0, 0,
  262. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 17, 18, 19, 20, 21, 22, 0, 0,
  263. 0, 1, 2, 3, 4, 5, 6, 7, 8, 13, 14, 11, 12, 17, 18, 15, 16, 21, 22, 19, 20
  264. };
  265. /* vim: set ts=4 sw=4 et : */
  266. #endif /* Z_RSS_H */