origamindee 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +89 -0
- data/COPYING.LESSER +165 -0
- data/README.md +131 -0
- data/bin/config/pdfcop.conf.yml +236 -0
- data/bin/pdf2pdfa +87 -0
- data/bin/pdf2ruby +333 -0
- data/bin/pdfcop +476 -0
- data/bin/pdfdecompress +97 -0
- data/bin/pdfdecrypt +91 -0
- data/bin/pdfencrypt +113 -0
- data/bin/pdfexplode +223 -0
- data/bin/pdfextract +277 -0
- data/bin/pdfmetadata +143 -0
- data/bin/pdfsh +12 -0
- data/bin/shell/console.rb +128 -0
- data/bin/shell/hexdump.rb +59 -0
- data/bin/shell/irbrc +69 -0
- data/examples/README.md +34 -0
- data/examples/attachments/attachment.rb +38 -0
- data/examples/attachments/nested_document.rb +51 -0
- data/examples/encryption/encryption.rb +28 -0
- data/examples/events/events.rb +72 -0
- data/examples/flash/flash.rb +37 -0
- data/examples/flash/helloworld.swf +0 -0
- data/examples/forms/javascript.rb +54 -0
- data/examples/forms/xfa.rb +115 -0
- data/examples/javascript/hello_world.rb +22 -0
- data/examples/javascript/js_emulation.rb +54 -0
- data/examples/loop/goto.rb +32 -0
- data/examples/loop/named.rb +33 -0
- data/examples/signature/signature.rb +65 -0
- data/examples/uri/javascript.rb +56 -0
- data/examples/uri/open-uri.rb +21 -0
- data/examples/uri/submitform.rb +47 -0
- data/lib/origami/3d.rb +364 -0
- data/lib/origami/acroform.rb +321 -0
- data/lib/origami/actions.rb +318 -0
- data/lib/origami/annotations.rb +711 -0
- data/lib/origami/array.rb +242 -0
- data/lib/origami/boolean.rb +90 -0
- data/lib/origami/catalog.rb +418 -0
- data/lib/origami/collections.rb +144 -0
- data/lib/origami/compound.rb +161 -0
- data/lib/origami/destinations.rb +252 -0
- data/lib/origami/dictionary.rb +192 -0
- data/lib/origami/encryption.rb +1084 -0
- data/lib/origami/extensions/fdf.rb +347 -0
- data/lib/origami/extensions/ppklite.rb +422 -0
- data/lib/origami/filespec.rb +197 -0
- data/lib/origami/filters/ascii.rb +211 -0
- data/lib/origami/filters/ccitt/tables.rb +267 -0
- data/lib/origami/filters/ccitt.rb +357 -0
- data/lib/origami/filters/crypt.rb +38 -0
- data/lib/origami/filters/dct.rb +54 -0
- data/lib/origami/filters/flate.rb +69 -0
- data/lib/origami/filters/jbig2.rb +57 -0
- data/lib/origami/filters/jpx.rb +47 -0
- data/lib/origami/filters/lzw.rb +170 -0
- data/lib/origami/filters/predictors.rb +292 -0
- data/lib/origami/filters/runlength.rb +129 -0
- data/lib/origami/filters.rb +364 -0
- data/lib/origami/font.rb +196 -0
- data/lib/origami/functions.rb +79 -0
- data/lib/origami/graphics/colors.rb +230 -0
- data/lib/origami/graphics/instruction.rb +98 -0
- data/lib/origami/graphics/path.rb +182 -0
- data/lib/origami/graphics/patterns.rb +174 -0
- data/lib/origami/graphics/render.rb +62 -0
- data/lib/origami/graphics/state.rb +149 -0
- data/lib/origami/graphics/text.rb +225 -0
- data/lib/origami/graphics/xobject.rb +918 -0
- data/lib/origami/graphics.rb +38 -0
- data/lib/origami/header.rb +75 -0
- data/lib/origami/javascript.rb +713 -0
- data/lib/origami/linearization.rb +330 -0
- data/lib/origami/metadata.rb +172 -0
- data/lib/origami/name.rb +135 -0
- data/lib/origami/null.rb +65 -0
- data/lib/origami/numeric.rb +181 -0
- data/lib/origami/obfuscation.rb +245 -0
- data/lib/origami/object.rb +760 -0
- data/lib/origami/optionalcontent.rb +183 -0
- data/lib/origami/outline.rb +54 -0
- data/lib/origami/outputintents.rb +85 -0
- data/lib/origami/page.rb +722 -0
- data/lib/origami/parser.rb +269 -0
- data/lib/origami/parsers/fdf.rb +56 -0
- data/lib/origami/parsers/pdf/lazy.rb +176 -0
- data/lib/origami/parsers/pdf/linear.rb +122 -0
- data/lib/origami/parsers/pdf.rb +118 -0
- data/lib/origami/parsers/ppklite.rb +57 -0
- data/lib/origami/pdf.rb +1108 -0
- data/lib/origami/reference.rb +134 -0
- data/lib/origami/signature.rb +702 -0
- data/lib/origami/stream.rb +705 -0
- data/lib/origami/string.rb +444 -0
- data/lib/origami/template/patterns.rb +56 -0
- data/lib/origami/template/widgets.rb +151 -0
- data/lib/origami/trailer.rb +190 -0
- data/lib/origami/tree.rb +62 -0
- data/lib/origami/version.rb +23 -0
- data/lib/origami/webcapture.rb +100 -0
- data/lib/origami/xfa/config.rb +453 -0
- data/lib/origami/xfa/connectionset.rb +146 -0
- data/lib/origami/xfa/datasets.rb +49 -0
- data/lib/origami/xfa/localeset.rb +42 -0
- data/lib/origami/xfa/package.rb +59 -0
- data/lib/origami/xfa/pdf.rb +73 -0
- data/lib/origami/xfa/signature.rb +42 -0
- data/lib/origami/xfa/sourceset.rb +43 -0
- data/lib/origami/xfa/stylesheet.rb +44 -0
- data/lib/origami/xfa/template.rb +1691 -0
- data/lib/origami/xfa/xdc.rb +42 -0
- data/lib/origami/xfa/xfa.rb +146 -0
- data/lib/origami/xfa/xfdf.rb +43 -0
- data/lib/origami/xfa/xmpmeta.rb +43 -0
- data/lib/origami/xfa.rb +62 -0
- data/lib/origami/xreftable.rb +557 -0
- data/lib/origami.rb +47 -0
- data/test/dataset/calc.pdf +85 -0
- data/test/dataset/crypto.pdf +36 -0
- data/test/dataset/empty.pdf +49 -0
- data/test/test_actions.rb +27 -0
- data/test/test_annotations.rb +68 -0
- data/test/test_forms.rb +30 -0
- data/test/test_native_types.rb +83 -0
- data/test/test_object_tree.rb +33 -0
- data/test/test_pages.rb +60 -0
- data/test/test_pdf.rb +20 -0
- data/test/test_pdf_attachment.rb +34 -0
- data/test/test_pdf_create.rb +24 -0
- data/test/test_pdf_encrypt.rb +102 -0
- data/test/test_pdf_parse.rb +134 -0
- data/test/test_pdf_parse_lazy.rb +69 -0
- data/test/test_pdf_sign.rb +97 -0
- data/test/test_streams.rb +184 -0
- data/test/test_xrefs.rb +67 -0
- metadata +280 -0
@@ -0,0 +1,211 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
This file is part of Origami, PDF manipulation framework for Ruby
|
4
|
+
Copyright (C) 2016 Guillaume Delugré.
|
5
|
+
|
6
|
+
Origami is free software: you can redistribute it and/or modify
|
7
|
+
it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
9
|
+
(at your option) any later version.
|
10
|
+
|
11
|
+
Origami is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU Lesser General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU Lesser General Public License
|
17
|
+
along with Origami. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
=end
|
20
|
+
|
21
|
+
module Origami
|
22
|
+
|
23
|
+
module Filter
|
24
|
+
|
25
|
+
class InvalidASCIIHexStringError < DecodeError #:nodoc:
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# Class representing a filter used to encode and decode data written into hexadecimal.
|
30
|
+
#
|
31
|
+
class ASCIIHex
|
32
|
+
include Filter
|
33
|
+
|
34
|
+
EOD = ">" #:nodoc:
|
35
|
+
|
36
|
+
#
|
37
|
+
# Encodes given data into upcase hexadecimal representation.
|
38
|
+
# _stream_:: The data to encode.
|
39
|
+
#
|
40
|
+
def encode(stream)
|
41
|
+
stream.unpack("H*").join.upcase
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
# Decodes given data writen into upcase hexadecimal representation.
|
46
|
+
# _string_:: The data to decode.
|
47
|
+
#
|
48
|
+
def decode(string)
|
49
|
+
input = string.include?(EOD) ? string[0...string.index(EOD)] : string
|
50
|
+
digits = input.delete(" \f\t\r\n\0")
|
51
|
+
|
52
|
+
# Ensure every digit is in the hexadecimal charset.
|
53
|
+
unless digits =~ /^\h*$/
|
54
|
+
digits = digits.match(/^\h*/).to_s
|
55
|
+
|
56
|
+
raise InvalidASCIIHexStringError.new("Invalid characters", input_data: string, decoded_data: [ digits ].pack('H*'))
|
57
|
+
end
|
58
|
+
|
59
|
+
[ digits ].pack "H*"
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
AHx = ASCIIHex
|
64
|
+
|
65
|
+
class InvalidASCII85StringError < DecodeError #:nodoc:
|
66
|
+
end
|
67
|
+
|
68
|
+
#
|
69
|
+
# Class representing a filter used to encode and decode data written in base85 encoding.
|
70
|
+
#
|
71
|
+
class ASCII85
|
72
|
+
include Filter
|
73
|
+
|
74
|
+
EOD = "~>" #:nodoc:
|
75
|
+
|
76
|
+
#
|
77
|
+
# Encodes given data into base85.
|
78
|
+
# _stream_:: The data to encode.
|
79
|
+
#
|
80
|
+
def encode(stream)
|
81
|
+
i = 0
|
82
|
+
code = "".b
|
83
|
+
input = stream.dup
|
84
|
+
|
85
|
+
while i < input.size do
|
86
|
+
|
87
|
+
if input.length - i < 4
|
88
|
+
addend = 4 - (input.length - i)
|
89
|
+
input << "\0" * addend
|
90
|
+
else
|
91
|
+
addend = 0
|
92
|
+
end
|
93
|
+
|
94
|
+
# Encode the 4 bytes input value into a 5 character string.
|
95
|
+
value = input[i, 4].unpack("L>")[0]
|
96
|
+
outblock = encode_block(value)
|
97
|
+
|
98
|
+
outblock = "z" if outblock == "!!!!!" and addend == 0
|
99
|
+
|
100
|
+
if addend != 0
|
101
|
+
outblock = outblock[0, 4 - addend + 1]
|
102
|
+
end
|
103
|
+
|
104
|
+
code << outblock
|
105
|
+
|
106
|
+
i = i + 4
|
107
|
+
end
|
108
|
+
|
109
|
+
code
|
110
|
+
end
|
111
|
+
|
112
|
+
#
|
113
|
+
# Decodes the given data encoded in base85.
|
114
|
+
# _string_:: The data to decode.
|
115
|
+
#
|
116
|
+
def decode(string)
|
117
|
+
input = filter_input(string)
|
118
|
+
|
119
|
+
i = 0
|
120
|
+
result = ''.b
|
121
|
+
|
122
|
+
while i < input.size
|
123
|
+
|
124
|
+
outblock = ""
|
125
|
+
value = 0
|
126
|
+
addend = 0
|
127
|
+
|
128
|
+
if input[i] == "z"
|
129
|
+
codelen = 1
|
130
|
+
else
|
131
|
+
codelen = 5
|
132
|
+
|
133
|
+
if input.length - i < codelen
|
134
|
+
raise InvalidASCII85StringError.new("Invalid length", input_data: string, decoded_data: result) if input.length - i == 1
|
135
|
+
|
136
|
+
addend = codelen - (input.length - i)
|
137
|
+
input << "u" * addend
|
138
|
+
end
|
139
|
+
|
140
|
+
# Decode the 5 characters input block into a 32 bit integer.
|
141
|
+
begin
|
142
|
+
value = decode_block input[i, codelen]
|
143
|
+
rescue InvalidASCII85StringError => error
|
144
|
+
error.input_data = string
|
145
|
+
error.decoded_data = result
|
146
|
+
raise(error)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
outblock = [ value ].pack "L>"
|
151
|
+
outblock = outblock[0, 4 - addend]
|
152
|
+
|
153
|
+
result << outblock
|
154
|
+
|
155
|
+
i = i + codelen
|
156
|
+
end
|
157
|
+
|
158
|
+
result
|
159
|
+
end
|
160
|
+
|
161
|
+
private
|
162
|
+
|
163
|
+
def filter_input(string)
|
164
|
+
string = string[0, string.index(EOD)] if string.include?(EOD)
|
165
|
+
string.delete(" \f\t\r\n\0")
|
166
|
+
end
|
167
|
+
|
168
|
+
#
|
169
|
+
# Encodes an integer value into an ASCII85 block of 5 characters.
|
170
|
+
#
|
171
|
+
def encode_block(value)
|
172
|
+
block = "".b
|
173
|
+
|
174
|
+
5.times do |p|
|
175
|
+
c = value / 85 ** (4 - p)
|
176
|
+
block << ("!".ord + c).chr
|
177
|
+
|
178
|
+
value -= c * 85 ** (4 - p)
|
179
|
+
end
|
180
|
+
|
181
|
+
block
|
182
|
+
end
|
183
|
+
|
184
|
+
#
|
185
|
+
# Decodes a 5 character ASCII85 block into an integer value.
|
186
|
+
#
|
187
|
+
def decode_block(block)
|
188
|
+
value = 0
|
189
|
+
|
190
|
+
5.times do |i|
|
191
|
+
byte = block[i].ord
|
192
|
+
|
193
|
+
if byte > "u".ord or byte < "!".ord
|
194
|
+
raise InvalidASCII85StringError, "Invalid character sequence: #{block.inspect}"
|
195
|
+
else
|
196
|
+
value += (byte - "!".ord) * 85 ** (4 - i)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
if value >= (1 << 32)
|
201
|
+
raise InvalidASCII85StringError, "Invalid value (#{value}) for block #{block.inspect}"
|
202
|
+
end
|
203
|
+
|
204
|
+
value
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
208
|
+
A85 = ASCII85
|
209
|
+
|
210
|
+
end
|
211
|
+
end
|
@@ -0,0 +1,267 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
This file is part of Origami, PDF manipulation framework for Ruby
|
4
|
+
Copyright (C) 2016 Guillaume Delugré.
|
5
|
+
|
6
|
+
Origami is free software: you can redistribute it and/or modify
|
7
|
+
it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
9
|
+
(at your option) any later version.
|
10
|
+
|
11
|
+
Origami is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU Lesser General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU Lesser General Public License
|
17
|
+
along with Origami. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
=end
|
20
|
+
|
21
|
+
module Origami
|
22
|
+
|
23
|
+
module Filter
|
24
|
+
|
25
|
+
class CCITTFax
|
26
|
+
|
27
|
+
def self.codeword(str) #:nodoc:
|
28
|
+
[ str.to_i(2), str.length ]
|
29
|
+
end
|
30
|
+
|
31
|
+
WHITE_TERMINAL_ENCODE_TABLE =
|
32
|
+
{
|
33
|
+
0 => '00110101',
|
34
|
+
1 => '000111',
|
35
|
+
2 => '0111',
|
36
|
+
3 => '1000',
|
37
|
+
4 => '1011',
|
38
|
+
5 => '1100',
|
39
|
+
6 => '1110',
|
40
|
+
7 => '1111',
|
41
|
+
8 => '10011',
|
42
|
+
9 => '10100',
|
43
|
+
10 => '00111',
|
44
|
+
11 => '01000',
|
45
|
+
12 => '001000',
|
46
|
+
13 => '000011',
|
47
|
+
14 => '110100',
|
48
|
+
15 => '110101',
|
49
|
+
16 => '101010',
|
50
|
+
17 => '101011',
|
51
|
+
18 => '0100111',
|
52
|
+
19 => '0001100',
|
53
|
+
20 => '0001000',
|
54
|
+
21 => '0010111',
|
55
|
+
22 => '0000011',
|
56
|
+
23 => '0000100',
|
57
|
+
24 => '0101000',
|
58
|
+
25 => '0101011',
|
59
|
+
26 => '0010011',
|
60
|
+
27 => '0100100',
|
61
|
+
28 => '0011000',
|
62
|
+
29 => '00000010',
|
63
|
+
30 => '00000011',
|
64
|
+
31 => '00011010',
|
65
|
+
32 => '00011011',
|
66
|
+
33 => '00010010',
|
67
|
+
34 => '00010011',
|
68
|
+
35 => '00010100',
|
69
|
+
36 => '00010101',
|
70
|
+
37 => '00010110',
|
71
|
+
38 => '00010111',
|
72
|
+
39 => '00101000',
|
73
|
+
40 => '00101001',
|
74
|
+
41 => '00101010',
|
75
|
+
42 => '00101011',
|
76
|
+
43 => '00101100',
|
77
|
+
44 => '00101101',
|
78
|
+
45 => '00000100',
|
79
|
+
46 => '00000101',
|
80
|
+
47 => '00001010',
|
81
|
+
48 => '00001011',
|
82
|
+
49 => '01010010',
|
83
|
+
50 => '01010011',
|
84
|
+
51 => '01010100',
|
85
|
+
52 => '01010101',
|
86
|
+
53 => '00100100',
|
87
|
+
54 => '00100101',
|
88
|
+
55 => '01011000',
|
89
|
+
56 => '01011001',
|
90
|
+
57 => '01011010',
|
91
|
+
58 => '01011011',
|
92
|
+
59 => '01001010',
|
93
|
+
60 => '01001011',
|
94
|
+
61 => '00110010',
|
95
|
+
62 => '00110011',
|
96
|
+
63 => '00110100'
|
97
|
+
}.map {|length, bits| [length, codeword(bits)]}.to_h
|
98
|
+
|
99
|
+
WHITE_TERMINAL_DECODE_TABLE = WHITE_TERMINAL_ENCODE_TABLE.invert
|
100
|
+
|
101
|
+
BLACK_TERMINAL_ENCODE_TABLE =
|
102
|
+
{
|
103
|
+
0 => '0000110111',
|
104
|
+
1 => '010',
|
105
|
+
2 => '11',
|
106
|
+
3 => '10',
|
107
|
+
4 => '011',
|
108
|
+
5 => '0011',
|
109
|
+
6 => '0010',
|
110
|
+
7 => '00011',
|
111
|
+
8 => '000101',
|
112
|
+
9 => '000100',
|
113
|
+
10 => '0000100',
|
114
|
+
11 => '0000101',
|
115
|
+
12 => '0000111',
|
116
|
+
13 => '00000100',
|
117
|
+
14 => '00000111',
|
118
|
+
15 => '000011000',
|
119
|
+
16 => '0000010111',
|
120
|
+
17 => '0000011000',
|
121
|
+
18 => '0000001000',
|
122
|
+
19 => '00001100111',
|
123
|
+
20 => '00001101000',
|
124
|
+
21 => '00001101100',
|
125
|
+
22 => '00000110111',
|
126
|
+
23 => '00000101000',
|
127
|
+
24 => '00000010111',
|
128
|
+
25 => '00000011000',
|
129
|
+
26 => '000011001010',
|
130
|
+
27 => '000011001011',
|
131
|
+
28 => '000011001100',
|
132
|
+
29 => '000011001101',
|
133
|
+
30 => '000001101000',
|
134
|
+
31 => '000001101001',
|
135
|
+
32 => '000001101010',
|
136
|
+
33 => '000001101011',
|
137
|
+
34 => '000011010010',
|
138
|
+
35 => '000011010011',
|
139
|
+
36 => '000011010100',
|
140
|
+
37 => '000011010101',
|
141
|
+
38 => '000011010110',
|
142
|
+
39 => '000011010111',
|
143
|
+
40 => '000001101100',
|
144
|
+
41 => '000001101101',
|
145
|
+
42 => '000011011010',
|
146
|
+
43 => '000011011011',
|
147
|
+
44 => '000001010100',
|
148
|
+
45 => '000001010101',
|
149
|
+
46 => '000001010110',
|
150
|
+
47 => '000001010111',
|
151
|
+
48 => '000001100100',
|
152
|
+
49 => '000001100101',
|
153
|
+
50 => '000001010010',
|
154
|
+
51 => '000001010011',
|
155
|
+
52 => '000000100100',
|
156
|
+
53 => '000000110111',
|
157
|
+
54 => '000000111000',
|
158
|
+
55 => '000000100111',
|
159
|
+
56 => '000000101000',
|
160
|
+
57 => '000001011000',
|
161
|
+
58 => '000001011001',
|
162
|
+
59 => '000000101011',
|
163
|
+
60 => '000000101100',
|
164
|
+
61 => '000001011010',
|
165
|
+
62 => '000001100110',
|
166
|
+
63 => '000001100111'
|
167
|
+
}.map {|length, bits| [length, codeword(bits)]}.to_h
|
168
|
+
|
169
|
+
BLACK_TERMINAL_DECODE_TABLE = BLACK_TERMINAL_ENCODE_TABLE.invert
|
170
|
+
|
171
|
+
WHITE_CONFIGURATION_ENCODE_TABLE =
|
172
|
+
{
|
173
|
+
64 => '11011',
|
174
|
+
128 => '10010',
|
175
|
+
192 => '010111',
|
176
|
+
256 => '0110111',
|
177
|
+
320 => '00110110',
|
178
|
+
384 => '00110111',
|
179
|
+
448 => '01100100',
|
180
|
+
512 => '01100101',
|
181
|
+
576 => '01101000',
|
182
|
+
640 => '01100111',
|
183
|
+
704 => '011001100',
|
184
|
+
768 => '011001101',
|
185
|
+
832 => '011010010',
|
186
|
+
896 => '011010011',
|
187
|
+
960 => '011010100',
|
188
|
+
1024 => '011010101',
|
189
|
+
1088 => '011010110',
|
190
|
+
1152 => '011010111',
|
191
|
+
1216 => '011011000',
|
192
|
+
1280 => '011011001',
|
193
|
+
1344 => '011011010',
|
194
|
+
1408 => '011011011',
|
195
|
+
1472 => '010011000',
|
196
|
+
1536 => '010011001',
|
197
|
+
1600 => '010011010',
|
198
|
+
1664 => '011000',
|
199
|
+
1728 => '010011011',
|
200
|
+
|
201
|
+
1792 => '00000001000',
|
202
|
+
1856 => '00000001100',
|
203
|
+
1920 => '00000001001',
|
204
|
+
1984 => '000000010010',
|
205
|
+
2048 => '000000010011',
|
206
|
+
2112 => '000000010100',
|
207
|
+
2176 => '000000010101',
|
208
|
+
2240 => '000000010110',
|
209
|
+
2340 => '000000010111',
|
210
|
+
2368 => '000000011100',
|
211
|
+
2432 => '000000011101',
|
212
|
+
2496 => '000000011110',
|
213
|
+
2560 => '000000011111'
|
214
|
+
}.map {|length, bits| [length, codeword(bits)]}.to_h
|
215
|
+
|
216
|
+
WHITE_CONFIGURATION_DECODE_TABLE = WHITE_CONFIGURATION_ENCODE_TABLE.invert
|
217
|
+
|
218
|
+
BLACK_CONFIGURATION_ENCODE_TABLE =
|
219
|
+
{
|
220
|
+
64 => '0000001111',
|
221
|
+
128 => '000011001000',
|
222
|
+
192 => '000011001001',
|
223
|
+
256 => '000001011011',
|
224
|
+
320 => '000000110011',
|
225
|
+
384 => '000000110100',
|
226
|
+
448 => '000000110101',
|
227
|
+
512 => '0000001101100',
|
228
|
+
576 => '0000001101101',
|
229
|
+
640 => '0000001001010',
|
230
|
+
704 => '0000001001011',
|
231
|
+
768 => '0000001001100',
|
232
|
+
832 => '0000001001101',
|
233
|
+
896 => '0000001110010',
|
234
|
+
960 => '0000001110011',
|
235
|
+
1024 => '0000001110100',
|
236
|
+
1088 => '0000001110101',
|
237
|
+
1152 => '0000001110110',
|
238
|
+
1216 => '0000001110111',
|
239
|
+
1280 => '0000001010010',
|
240
|
+
1344 => '0000001010011',
|
241
|
+
1408 => '0000001010100',
|
242
|
+
1472 => '0000001010101',
|
243
|
+
1536 => '0000001011010',
|
244
|
+
1600 => '0000001011011',
|
245
|
+
1664 => '0000001100100',
|
246
|
+
1728 => '0000001100101',
|
247
|
+
|
248
|
+
1792 => '00000001000',
|
249
|
+
1856 => '00000001100',
|
250
|
+
1920 => '00000001001',
|
251
|
+
1984 => '000000010010',
|
252
|
+
2048 => '000000010011',
|
253
|
+
2112 => '000000010100',
|
254
|
+
2176 => '000000010101',
|
255
|
+
2240 => '000000010110',
|
256
|
+
2340 => '000000010111',
|
257
|
+
2368 => '000000011100',
|
258
|
+
2432 => '000000011101',
|
259
|
+
2496 => '000000011110',
|
260
|
+
2560 => '000000011111'
|
261
|
+
}.map {|length, bits| [length, codeword(bits)]}.to_h
|
262
|
+
|
263
|
+
BLACK_CONFIGURATION_DECODE_TABLE = BLACK_CONFIGURATION_ENCODE_TABLE.invert
|
264
|
+
end
|
265
|
+
|
266
|
+
end
|
267
|
+
end
|