|
| 1 | +/* |
| 2 | + * shrink_inmem.h - in-memory compression definitions |
| 3 | + * |
| 4 | + * Copyright (C) 2019 Emmanuel Marty |
| 5 | + * |
| 6 | + * This software is provided 'as-is', without any express or implied |
| 7 | + * warranty. In no event will the authors be held liable for any damages |
| 8 | + * arising from the use of this software. |
| 9 | + * |
| 10 | + * Permission is granted to anyone to use this software for any purpose, |
| 11 | + * including commercial applications, and to alter it and redistribute it |
| 12 | + * freely, subject to the following restrictions: |
| 13 | + * |
| 14 | + * 1. The origin of this software must not be misrepresented; you must not |
| 15 | + * claim that you wrote the original software. If you use this software |
| 16 | + * in a product, an acknowledgment in the product documentation would be |
| 17 | + * appreciated but is not required. |
| 18 | + * 2. Altered source versions must be plainly marked as such, and must not be |
| 19 | + * misrepresented as being the original software. |
| 20 | + * 3. This notice may not be removed or altered from any source distribution. |
| 21 | + */ |
| 22 | + |
| 23 | +/* |
| 24 | + * Uses the libdivsufsort library Copyright (c) 2003-2008 Yuta Mori |
| 25 | + * |
| 26 | + * Inspired by LZ4 by Yann Collet. https://github.com/lz4/lz4 |
| 27 | + * With help, ideas, optimizations and speed measurements by spke <zxintrospec@gmail.com> |
| 28 | + * With ideas from Lizard by Przemyslaw Skibinski and Yann Collet. https://github.com/inikep/lizard |
| 29 | + * Also with ideas from smallz4 by Stephan Brumme. https://create.stephan-brumme.com/smallz4/ |
| 30 | + * |
| 31 | + */ |
| 32 | + |
| 33 | +/* !!! Modified from the original, to use as a library for 7800basic !!! */ |
| 34 | + |
| 35 | +#ifndef _SHRINK_INMEM_H |
| 36 | +#define _SHRINK_INMEM_H |
| 37 | + |
| 38 | +#include <stdlib.h> |
| 39 | + |
| 40 | +/** |
| 41 | + * Get maximum compressed size of input(source) data |
| 42 | + * |
| 43 | + * @param nInputSize input(source) size in bytes |
| 44 | + * |
| 45 | + * @return maximum compressed size |
| 46 | + */ |
| 47 | +extern size_t lzsa_get_max_compressed_size_inmem(size_t nInputSize); |
| 48 | + |
| 49 | +/** |
| 50 | + * Compress memory |
| 51 | + * |
| 52 | + * @param pInputData pointer to input(source) data to compress |
| 53 | + * @param pOutBuffer buffer for compressed data |
| 54 | + * @param nInputSize input(source) size in bytes |
| 55 | + * @param nMaxOutBufferSize maximum capacity of compression buffer |
| 56 | + * @param nFlags compression flags (LZSA_FLAG_xxx) |
| 57 | + * @param nMinMatchSize minimum match size |
| 58 | + * @param nFormatVersion version of format to use (1-2) |
| 59 | + * |
| 60 | + * @return actual compressed size, or -1 for error |
| 61 | + */ |
| 62 | +extern size_t lzsa_compress_inmem(unsigned char *pInputData, unsigned char *pOutBuffer, size_t nInputSize, size_t nMaxOutBufferSize, |
| 63 | + const unsigned int nFlags, const int nMinMatchSize, const int nFormatVersion); |
| 64 | + |
| 65 | +#endif /* _SHRINK_INMEM_H */ |
0 commit comments