extlzham 0.0.1.PROTOTYPE
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.md +27 -0
- data/README.md +21 -0
- data/Rakefile +143 -0
- data/contrib/lzham/LICENSE +22 -0
- data/contrib/lzham/README.md +209 -0
- data/contrib/lzham/include/lzham.h +781 -0
- data/contrib/lzham/lzhamcomp/lzham_comp.h +38 -0
- data/contrib/lzham/lzhamcomp/lzham_lzbase.cpp +244 -0
- data/contrib/lzham/lzhamcomp/lzham_lzbase.h +45 -0
- data/contrib/lzham/lzhamcomp/lzham_lzcomp.cpp +608 -0
- data/contrib/lzham/lzhamcomp/lzham_lzcomp_internal.cpp +1966 -0
- data/contrib/lzham/lzhamcomp/lzham_lzcomp_internal.h +472 -0
- data/contrib/lzham/lzhamcomp/lzham_lzcomp_state.cpp +1413 -0
- data/contrib/lzham/lzhamcomp/lzham_match_accel.cpp +562 -0
- data/contrib/lzham/lzhamcomp/lzham_match_accel.h +146 -0
- data/contrib/lzham/lzhamcomp/lzham_null_threading.h +97 -0
- data/contrib/lzham/lzhamcomp/lzham_pthreads_threading.cpp +229 -0
- data/contrib/lzham/lzhamcomp/lzham_pthreads_threading.h +520 -0
- data/contrib/lzham/lzhamcomp/lzham_threading.h +12 -0
- data/contrib/lzham/lzhamcomp/lzham_win32_threading.cpp +220 -0
- data/contrib/lzham/lzhamcomp/lzham_win32_threading.h +368 -0
- data/contrib/lzham/lzhamdecomp/lzham_assert.cpp +66 -0
- data/contrib/lzham/lzhamdecomp/lzham_assert.h +40 -0
- data/contrib/lzham/lzhamdecomp/lzham_checksum.cpp +73 -0
- data/contrib/lzham/lzhamdecomp/lzham_checksum.h +13 -0
- data/contrib/lzham/lzhamdecomp/lzham_config.h +23 -0
- data/contrib/lzham/lzhamdecomp/lzham_core.h +264 -0
- data/contrib/lzham/lzhamdecomp/lzham_decomp.h +37 -0
- data/contrib/lzham/lzhamdecomp/lzham_helpers.h +54 -0
- data/contrib/lzham/lzhamdecomp/lzham_huffman_codes.cpp +262 -0
- data/contrib/lzham/lzhamdecomp/lzham_huffman_codes.h +14 -0
- data/contrib/lzham/lzhamdecomp/lzham_lzdecomp.cpp +1527 -0
- data/contrib/lzham/lzhamdecomp/lzham_lzdecompbase.cpp +131 -0
- data/contrib/lzham/lzhamdecomp/lzham_lzdecompbase.h +89 -0
- data/contrib/lzham/lzhamdecomp/lzham_math.h +142 -0
- data/contrib/lzham/lzhamdecomp/lzham_mem.cpp +284 -0
- data/contrib/lzham/lzhamdecomp/lzham_mem.h +112 -0
- data/contrib/lzham/lzhamdecomp/lzham_platform.cpp +157 -0
- data/contrib/lzham/lzhamdecomp/lzham_platform.h +284 -0
- data/contrib/lzham/lzhamdecomp/lzham_prefix_coding.cpp +351 -0
- data/contrib/lzham/lzhamdecomp/lzham_prefix_coding.h +146 -0
- data/contrib/lzham/lzhamdecomp/lzham_symbol_codec.cpp +1484 -0
- data/contrib/lzham/lzhamdecomp/lzham_symbol_codec.h +556 -0
- data/contrib/lzham/lzhamdecomp/lzham_timer.cpp +147 -0
- data/contrib/lzham/lzhamdecomp/lzham_timer.h +99 -0
- data/contrib/lzham/lzhamdecomp/lzham_traits.h +141 -0
- data/contrib/lzham/lzhamdecomp/lzham_types.h +97 -0
- data/contrib/lzham/lzhamdecomp/lzham_utils.h +58 -0
- data/contrib/lzham/lzhamdecomp/lzham_vector.cpp +75 -0
- data/contrib/lzham/lzhamdecomp/lzham_vector.h +588 -0
- data/contrib/lzham/lzhamlib/lzham_lib.cpp +179 -0
- data/examples/basic.rb +48 -0
- data/ext/extconf.rb +26 -0
- data/ext/extlzham.c +741 -0
- data/gemstub.rb +22 -0
- data/lib/extlzham/version.rb +5 -0
- data/lib/extlzham.rb +153 -0
- metadata +135 -0
data/gemstub.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#vim: set fileencoding:utf-8
|
2
|
+
|
3
|
+
require_relative "lib/extlzham/version"
|
4
|
+
|
5
|
+
GEMSTUB = Gem::Specification.new do |s|
|
6
|
+
s.name = "extlzham"
|
7
|
+
s.version = LZHAM::VERSION
|
8
|
+
s.summary = "ruby binding for lzham"
|
9
|
+
s.description = <<EOS
|
10
|
+
ruby binding for lzham <https://github.com/richgel999/lzham_codec>.
|
11
|
+
EOS
|
12
|
+
s.homepage = "http://sourceforge.jp/projects/rutsubo/"
|
13
|
+
s.license = "2-clause BSD License"
|
14
|
+
s.author = "dearblue"
|
15
|
+
s.email = "dearblue@users.sourceforge.jp"
|
16
|
+
|
17
|
+
s.required_ruby_version = ">= 2.0"
|
18
|
+
s.add_development_dependency "rspec", "~> 2.14"
|
19
|
+
s.add_development_dependency "rake", "~> 10.0"
|
20
|
+
end
|
21
|
+
|
22
|
+
EXTRA.concat(FileList["contrib/lzham/{LICENSE,README.md,include/lzham.h,{lzhamcomp,lzhamdecomp,lzhamlib}/*.{h,hh,hxx,hpp,c,cc,cxx,cpp,C}}"])
|
data/lib/extlzham.rb
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
#vim: set fileencoding:utf-8
|
2
|
+
|
3
|
+
require "stringio"
|
4
|
+
|
5
|
+
ver = RbConfig::CONFIG["ruby_version"]
|
6
|
+
soname = File.basename(__FILE__, ".rb") << ".so"
|
7
|
+
lib = File.join(File.dirname(__FILE__), ver, soname)
|
8
|
+
if File.file?(lib)
|
9
|
+
require_relative File.join(ver, soname)
|
10
|
+
else
|
11
|
+
require_relative soname
|
12
|
+
end
|
13
|
+
|
14
|
+
require_relative "extlzham/version"
|
15
|
+
|
16
|
+
module LZHAM
|
17
|
+
#
|
18
|
+
# call-seq:
|
19
|
+
# encode(string, opts = {}) -> encoded string
|
20
|
+
# encode(out_stream, opts = {}) -> lzham encoder object
|
21
|
+
# encode(out_stream, opts = {}) { |encoder| ... } -> out_stream
|
22
|
+
#
|
23
|
+
# [RETURN (encoded string)]
|
24
|
+
# Return LZHAM'd binary string.
|
25
|
+
#
|
26
|
+
# [RETURN (lzham encoder object)]
|
27
|
+
# Return LZHAM encoder. When finished process, must call <tt>.finish</tt> method (as same as Zlib::Deflate#finish).
|
28
|
+
#
|
29
|
+
# [RETURN (out_stream)]
|
30
|
+
# Return out_stream parameter.
|
31
|
+
#
|
32
|
+
# [string]
|
33
|
+
# Input data as binary.
|
34
|
+
#
|
35
|
+
# [out_stream]
|
36
|
+
# Writable I/O liked object for LZHAM'd binary data.
|
37
|
+
#
|
38
|
+
# This object is called <tt><<</tt> method.
|
39
|
+
#
|
40
|
+
# This object is not closed after finished process.
|
41
|
+
#
|
42
|
+
# [opts (dictsize)]
|
43
|
+
# Set in lzham_compress_params.m_dict_size_log2. Default is <tt>LZHAM::MIN_DICT_SIZE_LOG2</tt>.
|
44
|
+
#
|
45
|
+
# [opts (level)]
|
46
|
+
# Set in lzham_compress_params.m_level. Default is <tt>LZHAM::COMP_LEVEL_DEFAULT</tt>.
|
47
|
+
#
|
48
|
+
# [opts (table_update_rate)]
|
49
|
+
# Set in lzham_compress_params.m_table_update_rate. Default is <tt>0</tt>.
|
50
|
+
#
|
51
|
+
# [opts (threads)]
|
52
|
+
# Set in lzham_compress_params.m_max_helper_threads. Default is <tt>-1</tt>.
|
53
|
+
#
|
54
|
+
# [opts (flags)]
|
55
|
+
# Set in lzham_compress_params.m_compress_flags. Default is <tt>0</tt>.
|
56
|
+
#
|
57
|
+
# [opts (table_max_update_interval)]
|
58
|
+
# Set in lzham_compress_params.m_table_max_update_interval. Default is <tt>0</tt>.
|
59
|
+
#
|
60
|
+
# [opts (table_update_interval_slow_rate)]
|
61
|
+
# Set in lzham_compress_params.m_table_update_interval_slow_rate. Default is <tt>0</tt>.
|
62
|
+
#
|
63
|
+
# [opts (seed)]
|
64
|
+
# Set in lzham_compress_params.m_pSeed_bytes and lzham_compress_params.m_num_seed_bytes.
|
65
|
+
#
|
66
|
+
# But this parameter is ignored currentry (not implemented).
|
67
|
+
#
|
68
|
+
# ==== example (when given string)
|
69
|
+
#
|
70
|
+
# require "extlzham"
|
71
|
+
# lzhamd = LZHAM.encode("This is not LZHAM'd string data." * 50)
|
72
|
+
# p lzhamd.class # => String
|
73
|
+
# p lzhamd # => ...binary data...
|
74
|
+
#
|
75
|
+
def self.encode(obj, *args)
|
76
|
+
if obj.kind_of?(String)
|
77
|
+
ex = LZHAM::Encoder.new(s = "".force_encoding(Encoding::BINARY), *args)
|
78
|
+
ex << obj
|
79
|
+
ex.finish
|
80
|
+
s
|
81
|
+
else
|
82
|
+
enc = Encoder.new(obj, *args)
|
83
|
+
return enc unless block_given?
|
84
|
+
begin
|
85
|
+
yield(enc)
|
86
|
+
obj
|
87
|
+
ensure
|
88
|
+
enc.finish
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
# call-seq:
|
95
|
+
# decode(string, opts = {}) -> decoded string
|
96
|
+
# decode(out_stream, opts = {}) -> lzham decoder object
|
97
|
+
# decode(out_stream, opts = {}) { |decoder| ... } -> out_stream
|
98
|
+
#
|
99
|
+
# [opts (dictsize)]
|
100
|
+
# Set in lzham_decompress_params.m_dict_size_log2. Default is <tt>LZHAM::MIN_DICT_SIZE_LOG2</tt>.
|
101
|
+
#
|
102
|
+
# [opts (table_update_rate)]
|
103
|
+
# Set in lzham_decompress_params.m_table_update_rate. Default is <tt>0</tt>.
|
104
|
+
#
|
105
|
+
# [opts (flags)]
|
106
|
+
# Set in lzham_decompress_params.m_compress_flags. Default is <tt>0</tt>.
|
107
|
+
#
|
108
|
+
# [opts (table_max_update_interval)]
|
109
|
+
# Set in lzham_decompress_params.m_table_max_update_interval. Default is <tt>0</tt>.
|
110
|
+
#
|
111
|
+
# [opts (table_update_interval_slow_rate)]
|
112
|
+
# Set in lzham_decompress_params.m_table_update_interval_slow_rate. Default is <tt>0</tt>.
|
113
|
+
#
|
114
|
+
# [opts (seed)]
|
115
|
+
# Set in lzham_decompress_params.m_pSeed_bytes and lzham_decompress_params.m_num_seed_bytes.
|
116
|
+
#
|
117
|
+
# But this parameter is ignored currentry (not implemented).
|
118
|
+
#
|
119
|
+
def self.decode(obj, *args)
|
120
|
+
if obj.kind_of?(String)
|
121
|
+
dx = LZHAM::Decoder.new(s = "".force_encoding(Encoding::BINARY), *args)
|
122
|
+
dx << obj
|
123
|
+
dx.finish
|
124
|
+
s
|
125
|
+
else
|
126
|
+
dec = Decoder.new(obj, *args)
|
127
|
+
return dec unless block_given?
|
128
|
+
begin
|
129
|
+
yield(dec)
|
130
|
+
obj
|
131
|
+
ensure
|
132
|
+
dec.finish
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
Compressor = Encoder
|
138
|
+
Decompressor = Decoder
|
139
|
+
Uncompressor = Decoder
|
140
|
+
|
141
|
+
class Encoder
|
142
|
+
alias encode update
|
143
|
+
alias compress update
|
144
|
+
alias close finish
|
145
|
+
end
|
146
|
+
|
147
|
+
class Decoder
|
148
|
+
alias decode update
|
149
|
+
alias decompress update
|
150
|
+
alias uncompress update
|
151
|
+
alias close finish
|
152
|
+
end
|
153
|
+
end
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: extlzham
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.PROTOTYPE
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- dearblue
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: |
|
42
|
+
ruby binding for lzham <https://github.com/richgel999/lzham_codec>.
|
43
|
+
email: dearblue@users.sourceforge.jp
|
44
|
+
executables: []
|
45
|
+
extensions:
|
46
|
+
- ext/extconf.rb
|
47
|
+
extra_rdoc_files:
|
48
|
+
- LICENSE.md
|
49
|
+
- README.md
|
50
|
+
- ext/extlzham.c
|
51
|
+
- lib/extlzham.rb
|
52
|
+
- lib/extlzham/version.rb
|
53
|
+
files:
|
54
|
+
- LICENSE.md
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- contrib/lzham/LICENSE
|
58
|
+
- contrib/lzham/README.md
|
59
|
+
- contrib/lzham/include/lzham.h
|
60
|
+
- contrib/lzham/lzhamcomp/lzham_comp.h
|
61
|
+
- contrib/lzham/lzhamcomp/lzham_lzbase.cpp
|
62
|
+
- contrib/lzham/lzhamcomp/lzham_lzbase.h
|
63
|
+
- contrib/lzham/lzhamcomp/lzham_lzcomp.cpp
|
64
|
+
- contrib/lzham/lzhamcomp/lzham_lzcomp_internal.cpp
|
65
|
+
- contrib/lzham/lzhamcomp/lzham_lzcomp_internal.h
|
66
|
+
- contrib/lzham/lzhamcomp/lzham_lzcomp_state.cpp
|
67
|
+
- contrib/lzham/lzhamcomp/lzham_match_accel.cpp
|
68
|
+
- contrib/lzham/lzhamcomp/lzham_match_accel.h
|
69
|
+
- contrib/lzham/lzhamcomp/lzham_null_threading.h
|
70
|
+
- contrib/lzham/lzhamcomp/lzham_pthreads_threading.cpp
|
71
|
+
- contrib/lzham/lzhamcomp/lzham_pthreads_threading.h
|
72
|
+
- contrib/lzham/lzhamcomp/lzham_threading.h
|
73
|
+
- contrib/lzham/lzhamcomp/lzham_win32_threading.cpp
|
74
|
+
- contrib/lzham/lzhamcomp/lzham_win32_threading.h
|
75
|
+
- contrib/lzham/lzhamdecomp/lzham_assert.cpp
|
76
|
+
- contrib/lzham/lzhamdecomp/lzham_assert.h
|
77
|
+
- contrib/lzham/lzhamdecomp/lzham_checksum.cpp
|
78
|
+
- contrib/lzham/lzhamdecomp/lzham_checksum.h
|
79
|
+
- contrib/lzham/lzhamdecomp/lzham_config.h
|
80
|
+
- contrib/lzham/lzhamdecomp/lzham_core.h
|
81
|
+
- contrib/lzham/lzhamdecomp/lzham_decomp.h
|
82
|
+
- contrib/lzham/lzhamdecomp/lzham_helpers.h
|
83
|
+
- contrib/lzham/lzhamdecomp/lzham_huffman_codes.cpp
|
84
|
+
- contrib/lzham/lzhamdecomp/lzham_huffman_codes.h
|
85
|
+
- contrib/lzham/lzhamdecomp/lzham_lzdecomp.cpp
|
86
|
+
- contrib/lzham/lzhamdecomp/lzham_lzdecompbase.cpp
|
87
|
+
- contrib/lzham/lzhamdecomp/lzham_lzdecompbase.h
|
88
|
+
- contrib/lzham/lzhamdecomp/lzham_math.h
|
89
|
+
- contrib/lzham/lzhamdecomp/lzham_mem.cpp
|
90
|
+
- contrib/lzham/lzhamdecomp/lzham_mem.h
|
91
|
+
- contrib/lzham/lzhamdecomp/lzham_platform.cpp
|
92
|
+
- contrib/lzham/lzhamdecomp/lzham_platform.h
|
93
|
+
- contrib/lzham/lzhamdecomp/lzham_prefix_coding.cpp
|
94
|
+
- contrib/lzham/lzhamdecomp/lzham_prefix_coding.h
|
95
|
+
- contrib/lzham/lzhamdecomp/lzham_symbol_codec.cpp
|
96
|
+
- contrib/lzham/lzhamdecomp/lzham_symbol_codec.h
|
97
|
+
- contrib/lzham/lzhamdecomp/lzham_timer.cpp
|
98
|
+
- contrib/lzham/lzhamdecomp/lzham_timer.h
|
99
|
+
- contrib/lzham/lzhamdecomp/lzham_traits.h
|
100
|
+
- contrib/lzham/lzhamdecomp/lzham_types.h
|
101
|
+
- contrib/lzham/lzhamdecomp/lzham_utils.h
|
102
|
+
- contrib/lzham/lzhamdecomp/lzham_vector.cpp
|
103
|
+
- contrib/lzham/lzhamdecomp/lzham_vector.h
|
104
|
+
- contrib/lzham/lzhamlib/lzham_lib.cpp
|
105
|
+
- examples/basic.rb
|
106
|
+
- ext/extconf.rb
|
107
|
+
- ext/extlzham.c
|
108
|
+
- gemstub.rb
|
109
|
+
- lib/extlzham.rb
|
110
|
+
- lib/extlzham/version.rb
|
111
|
+
homepage: http://sourceforge.jp/projects/rutsubo/
|
112
|
+
licenses:
|
113
|
+
- 2-clause BSD License
|
114
|
+
metadata: {}
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '2.0'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">"
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 1.3.1
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 2.4.5
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: ruby binding for lzham
|
135
|
+
test_files: []
|