-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: heatshrink_encoder.c Merge several PRs and other changes on `develop` over in preparation for 0.4.0 release. Closes #16. (Addressed directly by 15ebadd, and indirectly by several other changes.)
- Loading branch information
Showing
14 changed files
with
983 additions
and
328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ test_heatshrink_static | |
*.core | ||
*.dSYM | ||
*.exe | ||
benchmark_out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Contributing to heatshrink | ||
|
||
Thanks for taking time to contribute to heatshrink! | ||
|
||
Some issues may be tagged with `beginner` in the issue tracker, those | ||
should be particularly approachable. | ||
|
||
Please send pull requests against the `develop` branch. Changes need to | ||
be carefully checked for reverese compatibility before merging to | ||
`master`, since heatshrink is running on devices that may not be easily | ||
recalled and updated. | ||
|
||
|
||
## Documentation | ||
|
||
Improvements to the documentation are welcome. So are requests for | ||
clarification -- if the docs are unclear or misleading, that's a | ||
potential source of bugs. | ||
|
||
|
||
## Embedded & Portability Constraints | ||
|
||
heatshrink primarily targets embedded / real-time / memory-constrained | ||
systems, so enhancements that significantly increase memory or code | ||
space (ROM) requirements are probably out of scope. | ||
|
||
Changes that improve portability are welcome, and feedback from running | ||
on different embedded platforms is appreciated. | ||
|
||
|
||
## Versioning & Compatibility | ||
|
||
The versioning format is MAJOR.MINOR.PATCH. | ||
|
||
Performance improvements or minor bug fixes that do not break | ||
compatibility with past releases lead to patch version increases. API | ||
changes that do not break compatibility lead to minor version increases | ||
and reset the patch version, and changes that do break compatibility | ||
lead to a major version increase. | ||
|
||
Since heatshrink's compression and decompression sides may be used and | ||
updated independently, any change to the encoder that cannot be | ||
correctly decoded by earlier releases (or vice versa) is considered a | ||
breaking change. Changes to the encoder that lead to different output | ||
that earlier decoder releases handle correctly (such as pattern | ||
detection improvements) are *not* breaking changes. | ||
|
||
Essentially, improvements to the compression process that older releases | ||
can't decode correctly will need to wait until the next major release. | ||
|
||
|
||
## LZSS Algorithm | ||
|
||
heatshrink uses the [Lempel-Ziv-Storer-Szymanski][LZSS] algorithm for | ||
compression, with a few important implementation details: | ||
|
||
1. The compression and uncompression state machines have been designed | ||
to run incrementally - processing can work a few bytes at a time, | ||
suspending and resuming as additional data / buffer space becomes | ||
available. | ||
|
||
2. The optional [indexing technique][index] used to speed up compression | ||
is unique to heatshrink, as far as I know. | ||
|
||
3. In general, implementation trade-offs have favored low memory usage. | ||
|
||
[index]: http://spin.atomicobject.com/2014/01/13/lightweight-indexing-for-embedded-systems/ | ||
[LZSS]: http://en.wikipedia.org/wiki/Lempel-Ziv-Storer-Szymanski | ||
|
||
|
||
## Testing | ||
|
||
The unit tests are based on [greatest][g], with additional | ||
property-based tests using [theft][t] (which are currently not built by | ||
default). greatest tests are preferred for specific new functionality | ||
and for regression tests, while theft tests are preferred for | ||
integration tests (e.g. "for any input, compressing and uncompressing it | ||
should match the original"). Bugs found by theft make for great regression | ||
tests. | ||
|
||
Contributors are encouraged to add tests for any new functionality, and | ||
in particular to add regression tests for any bugs found. | ||
|
||
[g]: https://github.com/silentbicycle/greatest | ||
[t]: https://github.com/silentbicycle/theft | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/sh | ||
|
||
BENCHMARK_OUT=benchmark_out | ||
HS=../heatshrink | ||
|
||
cd ${BENCHMARK_OUT} | ||
|
||
# Files in the Canterbury Corpus | ||
# http://corpus.canterbury.ac.nz/resources/cantrbry.tar.gz | ||
FILES='alice29.txt | ||
asyoulik.txt | ||
cp.html | ||
fields.c | ||
grammar.lsp | ||
kennedy.xls | ||
lcet10.txt | ||
plrabn12.txt | ||
ptt5 | ||
sum | ||
xargs.1' | ||
|
||
rm -f benchmark.output | ||
|
||
# Run several combinations of -w W -l L, | ||
# note compression ratios and check uncompressed output matches input | ||
for W in 6 7 8 9 10 11 12; do | ||
for L in 5 6 7 8; do | ||
if [ $L -lt $W ]; then | ||
for f in ${FILES} | ||
do | ||
IN_FILE="${f}" | ||
COMPRESSED_FILE="${f}.hsz.${W}_${L}" | ||
UNCOMPRESSED_FILE="${f}.orig.${W}_${L}" | ||
${HS} -e -v -w ${W} -l ${L} ${IN_FILE} ${COMPRESSED_FILE} >> benchmark.output | ||
${HS} -d -v -w ${W} -l ${L} ${COMPRESSED_FILE} ${UNCOMPRESSED_FILE} > /dev/null | ||
|
||
if [ $(stat -f "%z" ${IN_FILE}) != $(stat -f "%z" ${UNCOMPRESSED_FILE}) ]; | ||
then | ||
printf "\n\n\nWARNING: size of %s does not match size of %s\n\n\n" \ | ||
${IN_FILE} ${UNCOMPRESSED_FILE} | ||
else | ||
printf "pass: -w %2d -l %2d %s\n" ${W} ${L} "${f}" | ||
fi | ||
|
||
rm ${COMPRESSED_FILE} ${UNCOMPRESSED_FILE} | ||
done | ||
fi | ||
done | ||
done | ||
|
||
# Print totals and averages | ||
awk '{ t += $2; c++ }; END { printf("====\nTotal compression: %.02f%% for %d documents (avg. %0.2f%%)\n", t, c, t / c) }' benchmark.output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.