Skip to content

Commit

Permalink
FEAT: optional custom LZ77-based compression algorithm (crush)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Dec 10, 2021
1 parent c33ff26 commit b7fb49b
Show file tree
Hide file tree
Showing 6 changed files with 460 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ Credits for Non-REBOL orginated C files and modules
Copyright (C) 2018, Igor Pavlov
Public domain - https://www.7-zip.org/sdk.html

* CRUSH (optional):
Copyright (C) 2013, Ilya Muravyov
Public domain - https://compressme.net/

* JPEG decoder:
Copyright 1994-1996, Thomas G. Lane.
This file is part of the Independent JPEG Group's software.
Expand Down
6 changes: 6 additions & 0 deletions make/rebol3.nest
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,11 @@ include-lzma-compression: [
core-files: %core/u-lzma.c
]

include-crush-compression: [
config: INCLUDE_CRUSH
core-files: %core/u-crush.c
]

include-png-filter-native: [
config: INCLUDE_PNG_FILTER
core-files: %core/u-png-filter.c
Expand Down Expand Up @@ -584,6 +589,7 @@ include-rebol-bulk: [
:include-optional-checksums
:include-image-natives
:include-lzma-compression
:include-crush-compression
:include-base85-encoding
:include-view
:include-midi
Expand Down
1 change: 1 addition & 0 deletions src/boot/sysobj.reb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ catalog: object [
uri-component: #[bitset! #{0000000041E6FFC07FFFFFE17FFFFFE2}] ;A-Z a-z 0-9 !'()*-._~
]
checksums: [adler32 crc24 crc32 tcp md4 md5 sha1 sha224 sha256 sha384 sha512 ripemd160]
compressions: [gzip deflate zlib lzma crush]
]

contexts: construct [
Expand Down
17 changes: 15 additions & 2 deletions src/core/n-strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
** REBOL [R3] Language Interpreter and Run-time Environment
**
** Copyright 2012 REBOL Technologies
** Copyright 2012-2021 Rebol Open Source Contributors
** REBOL is a trademark of REBOL Technologies
**
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -298,7 +299,13 @@ static struct digest {
Trap0(RE_FEATURE_NA);
#endif
break;

case SYM_CRUSH:
#ifdef INCLUDE_CRUSH
Set_Binary(D_RET, CompressCrush(ser, index, (REBINT)len, ref_level ? VAL_INT32(level) : 2));
#else
Trap0(RE_FEATURE_NA);
#endif
break;
default:
Trap1(RE_INVALID_ARG, D_ARG(2));
}
Expand Down Expand Up @@ -358,7 +365,13 @@ static struct digest {
Trap0(RE_FEATURE_NA);
#endif
break;

case SYM_CRUSH:
#ifdef INCLUDE_CRUSH
Set_Binary(D_RET, DecompressCrush(VAL_SERIES(data), VAL_INDEX(data), (REBINT)len, limit));
#else
Trap0(RE_FEATURE_NA);
#endif
break;
default:
Trap1(RE_INVALID_ARG, D_ARG(2));
}
Expand Down
Loading

0 comments on commit b7fb49b

Please sign in to comment.