Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

Commit

Permalink
yank ppmd_sh
Browse files Browse the repository at this point in the history
  • Loading branch information
kspalaiologos committed Oct 7, 2023
1 parent f0bc725 commit 28eaba7
Show file tree
Hide file tree
Showing 15 changed files with 13 additions and 158 deletions.
5 changes: 1 addition & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,4 @@
url = https://github.com/facebook/zstd
[submodule "vendor/bzip3"]
path = vendor/bzip3
url = https://github.com/kspalaiologos/bzip3
[submodule "vendor/ppmd_sh"]
path = vendor/ppmd_sh
url = https://github.com/Shelwien/ppmd_sh
url = https://github.com/kspalaiologos/bzip3
1 change: 0 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Conor McCarthy for Fast LZMA2
Serge Belyshev for encryption help and code
Ulrich Drepper for MD5 implementation
PolarSSL authors for sha512 + aes128 implementation
Dymitry Shkarin and Eugene Shelwien for PPMD_sh varJr1
Kamila Szewczyk for bzip3
Yann Collet for lz4 and zstandard
Matt Mahoney for zpaq
Expand Down
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

CONFIG=-Ivendor/zpaq -Ivendor/lz4/lib -Ivendor/zstd/lib -Ivendor/fast-lzma2 \
-Ivendor/bzip3/include -Ivendor/ppmd_sh -Ivendor/ppmd_sh/libpmd -Iinclude
-Ivendor/bzip3/include -Iinclude
PROGRAM=mrzip

all:
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
modern-rzip.
======================

A backup suite. Supports FLZMA2, PPMD, bzip3, LZ4, Zstandard, LSH i-node ordering deduplicating archiver, long range deduplication, encryption and recovery records. Also a refurbished partial rewrite of lrzip in active development.
A backup suite. Supports FLZMA2, bzip3, LZ4, Zstandard, LSH i-node ordering deduplicating archiver, long range deduplication, encryption and recovery records. Also a refurbished partial rewrite of lrzip in active development.

### Download, build and install
```
Expand All @@ -28,7 +28,6 @@ significantly faster compression than standalone compressors and much faster dec
**modern-rzip**'s compressors are:
* Fast LZMA2 (default)
* Zstandard
* PPMd_sh based on vJr1
* LZ4
* zpaq
* bzip3
Expand Down
2 changes: 0 additions & 2 deletions include/mrzip_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,5 @@ extern void zpaq_compress(uchar * c_buf, i64 * c_len, uchar * s_buf, i64 s_len,
bool progress, int thread);
extern void zpaq_decompress(uchar * s_buf, i64 * d_len, uchar * c_buf, i64 c_len, FILE * msgout, bool progress,
int thread);
int ppmdsh_varjr1_compress(char * input, int input_len, char * output, int * output_size, unsigned level);
int ppmdsh_varjr1_decompress(char * input, int input_len, char * output, int * output_size);

#endif
8 changes: 4 additions & 4 deletions include/mrzip_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ static inline unsigned char bzip3_prop_from_block_size(u32 bs) {
#define FLAG_DECOMPRESS (1 << 4)
#define FLAG_NO_COMPRESS (1 << 5)
#define FLAG_LZ4_COMPRESS (1 << 6)
#define FLAG_PPM_COMPRESS (1 << 7)
#define FLAG_UNUSED_COMPRESS (1 << 7)
#define FLAG_ZSTD_COMPRESS (1 << 8)
#define FLAG_ZPAQ_COMPRESS (1 << 9)
#define FLAG_VERBOSITY (1 << 10)
Expand All @@ -272,7 +272,7 @@ static inline unsigned char bzip3_prop_from_block_size(u32 bs) {
#define NO_HASH (!(HASH_CHECK) && !(HAS_HASH))

#define CTYPE_NONE 3
#define CTYPE_PPM 4
#define CTYPE_UNUSED 4
#define CTYPE_LZ4 5
#define CTYPE_LZMA 6
#define CTYPE_ZSTD 7
Expand Down Expand Up @@ -321,7 +321,7 @@ static inline unsigned char bzip3_prop_from_block_size(u32 bs) {

#define FLAG_VERBOSE (FLAG_VERBOSITY | FLAG_VERBOSITY_MAX)
#define FLAG_NOT_LZMA \
(FLAG_NO_COMPRESS | FLAG_LZ4_COMPRESS | FLAG_PPM_COMPRESS | FLAG_ZSTD_COMPRESS | FLAG_ZPAQ_COMPRESS | \
(FLAG_NO_COMPRESS | FLAG_LZ4_COMPRESS | FLAG_UNUSED_COMPRESS | FLAG_ZSTD_COMPRESS | FLAG_ZPAQ_COMPRESS | \
FLAG_BZIP3_COMPRESS)
#define LZMA_COMPRESS (!(control->flags & FLAG_NOT_LZMA))

Expand All @@ -332,7 +332,7 @@ static inline unsigned char bzip3_prop_from_block_size(u32 bs) {
#define DECOMPRESS (control->flags & FLAG_DECOMPRESS)
#define NO_COMPRESS (control->flags & FLAG_NO_COMPRESS)
#define LZ4_COMPRESS (control->flags & FLAG_LZ4_COMPRESS)
#define PPM_COMPRESS (control->flags & FLAG_PPM_COMPRESS)
#define UNUSED_COMPRESS (control->flags & FLAG_UNUSED_COMPRESS)
#define ZSTD_COMPRESS (control->flags & FLAG_ZSTD_COMPRESS)
#define ZPAQ_COMPRESS (control->flags & FLAG_ZPAQ_COMPRESS)
#define BZIP3_COMPRESS (control->flags & FLAG_BZIP3_COMPRESS)
Expand Down
8 changes: 1 addition & 7 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ static void usage(void) {
"Compression Options:\n"
"--------------------\n"
" --lzma lzma compression (default)\n"
" -s, --ppmdsh ppmd_sh varJr1 compression\n"
" -Z, --zstd zstd compression using zlib\n"
" -l, --lz4 lz4 compression (ultra fast)\n"
" -n, --no-compress no backend compression - prepare for other compressor\n"
Expand Down Expand Up @@ -181,8 +180,6 @@ static char * compression_type(void) {
return "LZMA";
else if (LZ4_COMPRESS)
return "LZ4";
else if (PPM_COMPRESS)
return "PPM";
else if (ZSTD_COMPRESS)
return "ZSTD";
else if (ZPAQ_COMPRESS)
Expand Down Expand Up @@ -253,7 +250,6 @@ static void show_summary(void) {
}

static struct option long_options[] = {
{ "ppmdsh", no_argument, 0, 's' }, /* 0 */
{ "check", no_argument, 0, 'c' },
{ "comment", required_argument, 0, 'C' },
{ "decompress", no_argument, 0, 'd' },
Expand Down Expand Up @@ -372,9 +368,7 @@ int main(int argc, char * argv[]) {
fatal("Can only use one of -l, -b, -g, -z, -B or -n\n");
/* Select Compression Mode */
control->flags &= ~FLAG_NOT_LZMA; /* must clear all compressions first */
if (c == 's')
control->flags |= FLAG_PPM_COMPRESS;
else if (c == 'Z')
if (c == 'Z')
control->flags |= FLAG_ZSTD_COMPRESS;
else if (c == 'l')
control->flags |= FLAG_LZ4_COMPRESS;
Expand Down
4 changes: 0 additions & 4 deletions src/mrzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,8 +883,6 @@ bool get_fileinfo(rzip_control * control) {
if (INFO) print_verbose("%'d\t", block);
if (ctype == CTYPE_NONE) {
if (INFO) print_verbose("none");
} else if (ctype == CTYPE_PPM) {
if (INFO) print_verbose("ppmdsh");
} else if (ctype == CTYPE_LZ4) {
if (INFO) print_verbose("lz4");
} else if (ctype == CTYPE_LZMA) {
Expand Down Expand Up @@ -962,8 +960,6 @@ bool get_fileinfo(rzip_control * control) {
print_output("Compression Method: ");
if (save_ctype == CTYPE_NONE)
print_output("rzip alone\n");
else if (save_ctype == CTYPE_PPM)
print_output("rzip + ppmdsh\n");
else if (save_ctype == CTYPE_LZ4)
print_output("rzip + lz4\n");
else if (save_ctype == CTYPE_LZMA) {
Expand Down
80 changes: 0 additions & 80 deletions src/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,44 +211,6 @@ static int zpaq_compress_buf(rzip_control * control, struct compress_thread * ct
return 0;
}

static int ppmdsh_compress_buf(rzip_control * control, struct compress_thread * cthread) {
u32 dlen = round_up_page(control, cthread->s_len + 10000);
int ppmdsh_ret;
uchar * c_buf;

if (LZ4_TEST) {
if (!lz4_compresses(control, cthread->s_buf, cthread->s_len)) return 0;
}

c_buf = malloc(dlen);
if (!c_buf) {
print_err("Unable to allocate c_buf in ppmdsh_compress_buf\n");
return -1;
}

// TODO: mapping between mem and compression lvl.
int res = ppmdsh_varjr1_compress(cthread->s_buf, cthread->s_len, c_buf, &dlen, control->compression_level);

if (unlikely(res != 0)) {
dealloc(c_buf);
print_maxverbose("PPMD_sh varJr1 compress failed\n");
return -1;
}

if (unlikely(dlen >= cthread->c_len)) {
print_maxverbose("Incompressible block\n");
/* Incompressible, leave as CTYPE_NONE */
dealloc(c_buf);
return 0;
}

cthread->c_len = dlen;
dealloc(cthread->s_buf);
cthread->s_buf = c_buf;
cthread->c_type = CTYPE_PPM;
return 0;
}

static int zstd_compress_buf(rzip_control * control, struct compress_thread * cthread) {
unsigned long dlen = round_up_page(control, ZSTD_COMPRESSBOUND(cthread->s_len));
uchar * c_buf;
Expand Down Expand Up @@ -416,41 +378,6 @@ static int zpaq_decompress_buf(rzip_control * control, struct uncomp_thread * uc
return ret;
}

static int ppmdsh_decompress_buf(rzip_control * control, struct uncomp_thread * ucthread) {
u32 dlen = ucthread->u_len + 10;
int ret = 0, bzerr;
uchar * c_buf;

c_buf = ucthread->s_buf;
ucthread->s_buf = malloc(round_up_page(control, dlen));
if (unlikely(!ucthread->s_buf)) {
print_err("Failed to allocate %'d bytes for decompression\n", dlen);
ret = -1;
goto out;
}

bzerr = ppmdsh_varjr1_decompress(c_buf, ucthread->c_len, ucthread->s_buf, &dlen);

if (unlikely(bzerr != 0)) {
print_err("Failed to decompress buffer - bzerr=%'d\n", bzerr);
ret = -1;
goto out;
}

if (unlikely(dlen != ucthread->u_len)) {
print_err("Inconsistent length after decompression. Got %'d bytes, expected %'" PRId64 "\n", dlen,
ucthread->u_len);
ret = -1;
} else
dealloc(c_buf);
out:
if (ret == -1) {
dealloc(ucthread->s_buf);
ucthread->s_buf = c_buf;
}
return ret;
}

static int zstd_decompress_buf(rzip_control * control, struct uncomp_thread * ucthread) {
unsigned long dlen = ucthread->u_len;
int ret = 0;
Expand Down Expand Up @@ -977,8 +904,6 @@ void * open_stream_out(rzip_control * control, int f, unsigned int n, i64 chunk_
stream_bufsize = round_up_page(control, (0x100000 << control->zpaq_bs) - 0x1000);
else if (BZIP3_COMPRESS && (limit / control->threads > control->bzip3_block_size))
stream_bufsize = round_up_page(control, control->bzip3_block_size - 0x1000);
else if (PPM_COMPRESS && (limit / control->threads > 0x100000 << control->bzip3_bs))
stream_bufsize = round_up_page(control, (0x100000 << control->bzip3_bs) - 0x1000);
else if (LZMA_COMPRESS && limit / control->threads > STREAM_BUFSIZE)
// for smaller dictionary sizes, need MAX test to bring in larger buffer from limit
// limit = usable ram / 2
Expand Down Expand Up @@ -1225,8 +1150,6 @@ static void * compthread(void * data) {
ret = lzma_compress_buf(control, cti, current_thread);
else if (LZ4_COMPRESS)
ret = lz4_compress_buf(control, cti);
else if (PPM_COMPRESS)
ret = ppmdsh_compress_buf(control, cti);
else if (ZSTD_COMPRESS)
ret = zstd_compress_buf(control, cti);
else if (ZPAQ_COMPRESS)
Expand Down Expand Up @@ -1448,9 +1371,6 @@ static void * ucompthread(void * data) {
case CTYPE_LZ4:
ret = lz4_decompress_buf(control, uci);
break;
case CTYPE_PPM:
ret = ppmdsh_decompress_buf(control, uci);
break;
case CTYPE_ZSTD:
ret = zstd_decompress_buf(control, uci);
break;
Expand Down
8 changes: 2 additions & 6 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ void setup_overhead(rzip_control * control) {
}
control->bzip3_block_size = BZIP3_BLOCK_SIZE_FROM_PROP(control->bzip3_bs);
control->overhead = (i64)control->bzip3_block_size * 6;
} else if (PPM_COMPRESS) {
control->overhead = (i64)(1 << control->compression_level) * ONE_MB;
}

/* no need for zpaq computation here. do in open_stream_out() */
Expand Down Expand Up @@ -229,11 +227,9 @@ bool read_config(rzip_control * control) {
if (control->rzip_compression_level < 1 || control->rzip_compression_level > 9)
fatal("CONF.FILE error. RZIP Compression Level must between 1 and 9\n");
} else if (isparameter(parameter, "compressionmethod")) {
/* valid are rzip, zstd, ppmdsh, lz4, lzma (default), and zpaq */
/* valid are rzip, zstd, lz4, lzma (default), and zpaq */
if (control->flags & FLAG_NOT_LZMA) fatal("CONF.FILE error. Can only specify one compression method\n");
if (isparameter(parametervalue, "ppmdsh"))
control->flags |= FLAG_PPM_COMPRESS;
else if (isparameter(parametervalue, "zstd"))
if (isparameter(parametervalue, "zstd"))
control->flags |= FLAG_ZSTD_COMPRESS;
else if (isparameter(parametervalue, "lz4"))
control->flags |= FLAG_LZ4_COMPRESS;
Expand Down
2 changes: 1 addition & 1 deletion vendor/bzip3
43 changes: 0 additions & 43 deletions vendor/cxx_glue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,46 +106,3 @@ void libzpaq::error(const char * msg) { // print message and exit
fprintf(stderr, "ZPAQ Error: %s\n", msg);
exit(1);
}

#include <gcrypt.h>

#include "common.inc"
#include "coro3b_fake.inc"
#include "libpmd.inc"

int g_getc(FILE * f, FILE * g) { return fgetc(f); }
void g_putc(int c, FILE * f, FILE * g) { fputc(c, g); }

extern "C" {
int ppmdsh_varjr1_compress(char * input, int input_len, char * output, int * output_size, unsigned level) {
ALIGN(4096) pmd_codec C;
uint pmd_args[] = { 12 /* Order */, static_cast<uint>(1 << level) /* Memory */, 1 /* Restore */,
static_cast<uint>(input_len) };
if (C.Init(0, pmd_args)) return -1;
C.f = fmemopen(input, input_len, "rb");
C.g = fmemopen(output, *output_size, "wb");
fputc(level, C.g);
C.coro_call(&C);
C.Quit();
fflush(C.g);
*output_size = ftell(C.g);
fclose(C.f);
fclose(C.g);
return 0;
}

int ppmdsh_varjr1_decompress(char * input, int input_len, char * output, int * output_size) {
ALIGN(4096) pmd_codec C;
uint pmd_args[] = { 12 /* Order */, static_cast<uint>((*input) << 1) /* Memory */, 1 /* Restore */, -1U };
if (C.Init(1, pmd_args)) return -1;
C.f = fmemopen(input + 1, input_len - 1, "rb");
C.g = fmemopen(output, *output_size, "wb");
C.coro_call(&C);
C.Quit();
fflush(C.g);
*output_size = ftell(C.g);
fclose(C.f);
fclose(C.g);
return 0;
}
}
2 changes: 1 addition & 1 deletion vendor/lz4
Submodule lz4 updated 66 files
+7 −7 .circleci/config.yml
+82 −65 .github/workflows/ci.yml
+65 −0 .github/workflows/scorecard.yml
+5 −0 .gitignore
+0 −42 .travis.yml
+4 −4 Makefile
+16 −14 Makefile.inc
+16 −5 README.md
+17 −0 SECURITY.md
+1 −1 appveyor.yml
+2 −0 build/.gitignore
+1 −0 build/README.md
+39 −0 build/VS2022/_build.bat
+35 −0 build/VS2022/_setup.bat
+38 −0 build/VS2022/_test.bat
+26 −0 build/VS2022/build-and-test-win32-debug.bat
+26 −0 build/VS2022/build-and-test-win32-release.bat
+26 −0 build/VS2022/build-and-test-x64-debug.bat
+26 −0 build/VS2022/build-and-test-x64-release.bat
+5 −2 build/VS2022/lz4.sln
+51 −0 build/VS2022/lz4/lz4.rc
+185 −0 build/VS2022/lz4/lz4.vcxproj
+13 −11 build/cmake/CMakeLists.txt
+0 −0 build/meson/GetLz4LibraryVersion.py
+0 −0 build/meson/README.md
+0 −0 build/meson/meson.build
+0 −0 build/meson/meson/contrib/gen_manual/meson.build
+0 −0 build/meson/meson/contrib/meson.build
+7 −7 build/meson/meson/examples/meson.build
+16 −9 build/meson/meson/lib/meson.build
+0 −0 build/meson/meson/meson.build
+0 −0 build/meson/meson/ossfuzz/meson.build
+0 −0 build/meson/meson/programs/meson.build
+3 −2 build/meson/meson/tests/meson.build
+0 −0 build/meson/meson_options.txt
+8 −7 examples/.gitignore
+29 −53 examples/Makefile
+47 −37 examples/bench_functions.c
+2 −1 examples/fileCompress.c
+0 −0 examples/print_version.c
+0 −0 examples/streamingHC_ringBuffer.c
+19 −12 lib/Makefile
+24 −23 lib/lz4.c
+1 −1 lib/lz4.h
+1 −0 lib/lz4file.c
+7 −5 lib/lz4frame.c
+9 −3 lib/lz4frame.h
+47 −4 lib/lz4hc.c
+1 −1 ossfuzz/decompress_fuzzer.c
+1 −1 ossfuzz/fuzz_helpers.h
+4 −4 programs/bench.c
+14 −5 programs/lz4cli.c
+22 −11 programs/lz4io.c
+1 −0 programs/platform.h
+8 −13 programs/util.h
+46 −15 tests/Makefile
+78 −69 tests/checkFrame.c
+23 −0 tests/cmake/CMakeLists.txt
+3 −1 tests/datagencli.c
+2 −2 tests/decompress-partial.c
+117 −55 tests/frametest.c
+0 −1 tests/freestanding.c
+13 −12 tests/fuzzer.c
+2 −1 tests/test-lz4-abi.py
+19 −16 tests/test-lz4-basic.sh
+2 −2 tests/test-lz4-list.py
1 change: 0 additions & 1 deletion vendor/ppmd_sh
Submodule ppmd_sh deleted from a4230c
2 changes: 1 addition & 1 deletion vendor/zstd
Submodule zstd updated 417 files

0 comments on commit 28eaba7

Please sign in to comment.