lzfse 0.0.1.pre.4
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/.yardopts +1 -0
- data/LICENSE +21 -0
- data/README.md +38 -0
- data/ext/lzfse/LICENSE +27 -0
- data/ext/lzfse/ext.c +194 -0
- data/ext/lzfse/ext.h +14 -0
- data/ext/lzfse/extconf.rb +10 -0
- data/ext/lzfse/lzfse.h +136 -0
- data/ext/lzfse/lzfse_decode.c +72 -0
- data/ext/lzfse/lzfse_decode_base.c +630 -0
- data/ext/lzfse/lzfse_encode.c +163 -0
- data/ext/lzfse/lzfse_encode_base.c +830 -0
- data/ext/lzfse/lzfse_encode_tables.h +218 -0
- data/ext/lzfse/lzfse_fse.c +216 -0
- data/ext/lzfse/lzfse_fse.h +631 -0
- data/ext/lzfse/lzfse_internal.h +616 -0
- data/ext/lzfse/lzfse_tunables.h +60 -0
- data/ext/lzfse/lzvn_decode_base.c +711 -0
- data/ext/lzfse/lzvn_decode_base.h +68 -0
- data/ext/lzfse/lzvn_encode_base.c +593 -0
- data/ext/lzfse/lzvn_encode_base.h +116 -0
- data/lib/lzfse.rb +25 -0
- data/lib/lzfse/exceptions.rb +12 -0
- data/lib/lzfse/version.rb +5 -0
- data/vendor/bundle/ruby/2.7.0/gems/rainbow-3.0.0/LICENSE +20 -0
- data/vendor/bundle/ruby/2.7.0/gems/regexp_parser-2.1.1/LICENSE +22 -0
- data/vendor/bundle/ruby/2.7.0/gems/yard-0.9.26/LICENSE +22 -0
- metadata +126 -0
@@ -0,0 +1,116 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2015-2016, Apple Inc. All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
5
|
+
|
6
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
7
|
+
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
|
9
|
+
in the documentation and/or other materials provided with the distribution.
|
10
|
+
|
11
|
+
3. Neither the name of the copyright holder(s) nor the names of any contributors may be used to endorse or promote products derived
|
12
|
+
from this software without specific prior written permission.
|
13
|
+
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
15
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
16
|
+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
17
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
18
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
19
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
20
|
+
*/
|
21
|
+
|
22
|
+
// LZVN low-level encoder
|
23
|
+
|
24
|
+
#ifndef LZVN_ENCODE_BASE_H
|
25
|
+
#define LZVN_ENCODE_BASE_H
|
26
|
+
|
27
|
+
#include "lzfse_internal.h"
|
28
|
+
|
29
|
+
// ===============================================================
|
30
|
+
// Types and Constants
|
31
|
+
|
32
|
+
#define LZVN_ENCODE_HASH_BITS \
|
33
|
+
14 // number of bits returned by the hash function [10, 16]
|
34
|
+
#define LZVN_ENCODE_OFFSETS_PER_HASH \
|
35
|
+
4 // stored offsets stack for each hash value, MUST be 4
|
36
|
+
#define LZVN_ENCODE_HASH_VALUES \
|
37
|
+
(1 << LZVN_ENCODE_HASH_BITS) // number of entries in hash table
|
38
|
+
#define LZVN_ENCODE_MAX_DISTANCE \
|
39
|
+
0xffff // max match distance we can represent with LZVN encoding, MUST be
|
40
|
+
// 0xFFFF
|
41
|
+
#define LZVN_ENCODE_MIN_MARGIN \
|
42
|
+
8 // min number of bytes required between current and end during encoding,
|
43
|
+
// MUST be >= 8
|
44
|
+
#define LZVN_ENCODE_MAX_LITERAL_BACKLOG \
|
45
|
+
400 // if the number of pending literals exceeds this size, emit a long
|
46
|
+
// literal, MUST be >= 271
|
47
|
+
|
48
|
+
/*! @abstract Type of table entry. */
|
49
|
+
typedef struct {
|
50
|
+
int32_t indices[4]; // signed indices in source buffer
|
51
|
+
uint32_t values[4]; // corresponding 32-bit values
|
52
|
+
} lzvn_encode_entry_type;
|
53
|
+
|
54
|
+
// Work size
|
55
|
+
#define LZVN_ENCODE_WORK_SIZE \
|
56
|
+
(LZVN_ENCODE_HASH_VALUES * sizeof(lzvn_encode_entry_type))
|
57
|
+
|
58
|
+
/*! @abstract Match */
|
59
|
+
typedef struct {
|
60
|
+
lzvn_offset m_begin; // beginning of match, current position
|
61
|
+
lzvn_offset m_end; // end of match, this is where the next literal would begin
|
62
|
+
// if we emit the entire match
|
63
|
+
lzvn_offset M; // match length M: m_end - m_begin
|
64
|
+
lzvn_offset D; // match distance D
|
65
|
+
lzvn_offset K; // match gain: M - distance storage (L not included)
|
66
|
+
} lzvn_match_info;
|
67
|
+
|
68
|
+
// ===============================================================
|
69
|
+
// Internal encoder state
|
70
|
+
|
71
|
+
/*! @abstract Base encoder state and I/O. */
|
72
|
+
typedef struct {
|
73
|
+
|
74
|
+
// Encoder I/O
|
75
|
+
|
76
|
+
// Source buffer
|
77
|
+
const unsigned char *src;
|
78
|
+
// Valid range in source buffer: we can access src[i] for src_begin <= i <
|
79
|
+
// src_end. src_begin may be negative.
|
80
|
+
lzvn_offset src_begin;
|
81
|
+
lzvn_offset src_end;
|
82
|
+
// Next byte to process in source buffer
|
83
|
+
lzvn_offset src_current;
|
84
|
+
// Next byte after the last byte to process in source buffer. We MUST have:
|
85
|
+
// src_current_end + 8 <= src_end.
|
86
|
+
lzvn_offset src_current_end;
|
87
|
+
// Next byte to encode in source buffer, may be before or after src_current.
|
88
|
+
lzvn_offset src_literal;
|
89
|
+
|
90
|
+
// Next byte to write in destination buffer
|
91
|
+
unsigned char *dst;
|
92
|
+
// Valid range in destination buffer: [dst_begin, dst_end - 1]
|
93
|
+
unsigned char *dst_begin;
|
94
|
+
unsigned char *dst_end;
|
95
|
+
|
96
|
+
// Encoder state
|
97
|
+
|
98
|
+
// Pending match
|
99
|
+
lzvn_match_info pending;
|
100
|
+
|
101
|
+
// Distance for last emitted match, or 0
|
102
|
+
lzvn_offset d_prev;
|
103
|
+
|
104
|
+
// Hash table used to find matches. Stores LZVN_ENCODE_OFFSETS_PER_HASH 32-bit
|
105
|
+
// signed indices in the source buffer, and the corresponding 4-byte values.
|
106
|
+
// The number of entries in the table is LZVN_ENCODE_HASH_VALUES.
|
107
|
+
lzvn_encode_entry_type *table;
|
108
|
+
|
109
|
+
} lzvn_encoder_state;
|
110
|
+
|
111
|
+
/*! @abstract Encode source to destination.
|
112
|
+
* Update \p state.
|
113
|
+
* The call ensures \c src_literal is never left too far behind \c src_current. */
|
114
|
+
void lzvn_encode(lzvn_encoder_state *state);
|
115
|
+
|
116
|
+
#endif // LZVN_ENCODE_BASE_H
|
data/lib/lzfse.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lzfse/exceptions"
|
4
|
+
require_relative "ext/lzfse"
|
5
|
+
|
6
|
+
# The main module for *lzfse.rb*.
|
7
|
+
module LZFSE
|
8
|
+
module_function
|
9
|
+
|
10
|
+
def lzfse_compress(string)
|
11
|
+
lzfse_encode_intern string
|
12
|
+
end
|
13
|
+
|
14
|
+
def lzfse_decompress(string)
|
15
|
+
lzfse_decode_intern string
|
16
|
+
end
|
17
|
+
|
18
|
+
def lzvn_compress(string)
|
19
|
+
lzvn_encode_intern string
|
20
|
+
end
|
21
|
+
|
22
|
+
def lzvn_decompress(string)
|
23
|
+
lzvn_decode_intern string
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) Marcin Kulik
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2010, 2012-2015, Ammar Ali
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2007-2018 Loren Segal
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lzfse
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.pre.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- William Woodruff
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-05-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake-compiler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Ruby bindings for Apple's LZFSE (+ LZVN)
|
70
|
+
email: william@yossarian.net
|
71
|
+
executables: []
|
72
|
+
extensions:
|
73
|
+
- ext/lzfse/extconf.rb
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".yardopts"
|
77
|
+
- LICENSE
|
78
|
+
- README.md
|
79
|
+
- ext/lzfse/LICENSE
|
80
|
+
- ext/lzfse/ext.c
|
81
|
+
- ext/lzfse/ext.h
|
82
|
+
- ext/lzfse/extconf.rb
|
83
|
+
- ext/lzfse/lzfse.h
|
84
|
+
- ext/lzfse/lzfse_decode.c
|
85
|
+
- ext/lzfse/lzfse_decode_base.c
|
86
|
+
- ext/lzfse/lzfse_encode.c
|
87
|
+
- ext/lzfse/lzfse_encode_base.c
|
88
|
+
- ext/lzfse/lzfse_encode_tables.h
|
89
|
+
- ext/lzfse/lzfse_fse.c
|
90
|
+
- ext/lzfse/lzfse_fse.h
|
91
|
+
- ext/lzfse/lzfse_internal.h
|
92
|
+
- ext/lzfse/lzfse_tunables.h
|
93
|
+
- ext/lzfse/lzvn_decode_base.c
|
94
|
+
- ext/lzfse/lzvn_decode_base.h
|
95
|
+
- ext/lzfse/lzvn_encode_base.c
|
96
|
+
- ext/lzfse/lzvn_encode_base.h
|
97
|
+
- lib/lzfse.rb
|
98
|
+
- lib/lzfse/exceptions.rb
|
99
|
+
- lib/lzfse/version.rb
|
100
|
+
- vendor/bundle/ruby/2.7.0/gems/rainbow-3.0.0/LICENSE
|
101
|
+
- vendor/bundle/ruby/2.7.0/gems/regexp_parser-2.1.1/LICENSE
|
102
|
+
- vendor/bundle/ruby/2.7.0/gems/yard-0.9.26/LICENSE
|
103
|
+
homepage: https://github.com/woodruffw/lzfse.rb
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '2.7'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">"
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 1.3.1
|
121
|
+
requirements: []
|
122
|
+
rubygems_version: 3.1.4
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: Ruby bindings for Apple's LZFSE (+ LZVN)
|
126
|
+
test_files: []
|