2017-12-29 10:45:37 -07:00
|
|
|
/*!
|
|
|
|
\ingroup Compression
|
2018-06-27 16:22:12 -06:00
|
|
|
|
|
|
|
\brief This function compresses the given input data using Huffman coding
|
|
|
|
and stores the output in out. Note that the output buffer should still be
|
|
|
|
larger than the input buffer because there exists a certain input for
|
|
|
|
which there will be no compression possible, which will still require a
|
|
|
|
lookup table. It is recommended that one allocate srcSz + 0.1% + 12 for
|
2017-12-29 10:45:37 -07:00
|
|
|
the output buffer.
|
2018-06-27 16:22:12 -06:00
|
|
|
|
|
|
|
\return On successfully compressing the input data, returns the number
|
2017-12-29 10:45:37 -07:00
|
|
|
of bytes stored in the output buffer
|
2018-06-27 16:22:12 -06:00
|
|
|
\return COMPRESS_INIT_E Returned if there is an error initializing the
|
2017-12-29 10:45:37 -07:00
|
|
|
stream for compression
|
|
|
|
\return COMPRESS_E Returned if an error occurs during compression
|
|
|
|
|
2018-06-27 16:22:12 -06:00
|
|
|
\param out pointer to the output buffer in which to store the compressed
|
2017-12-29 10:45:37 -07:00
|
|
|
data
|
2018-06-27 16:22:12 -06:00
|
|
|
\param outSz size available in the output buffer for storage
|
2017-12-29 10:45:37 -07:00
|
|
|
\param in pointer to the buffer containing the message to compress
|
|
|
|
\param inSz size of the input message to compress
|
2018-06-27 16:22:12 -06:00
|
|
|
\param flags flags to control how compression operates. Use 0 for normal
|
2017-12-29 10:45:37 -07:00
|
|
|
decompression
|
2018-06-27 16:22:12 -06:00
|
|
|
|
2017-12-29 10:45:37 -07:00
|
|
|
_Example_
|
|
|
|
\code
|
|
|
|
byte message[] = { // initialize text to compress };
|
2018-06-27 16:22:12 -06:00
|
|
|
byte compressed[(sizeof(message) + sizeof(message) * .001 + 12 )];
|
2017-12-29 10:45:37 -07:00
|
|
|
// Recommends at least srcSz + .1% + 12
|
|
|
|
|
2018-06-27 16:22:12 -06:00
|
|
|
if( wc_Compress(compressed, sizeof(compressed), message, sizeof(message),
|
|
|
|
0) != 0){
|
2017-12-29 10:45:37 -07:00
|
|
|
// error compressing data
|
|
|
|
}
|
|
|
|
\endcode
|
2018-06-27 16:22:12 -06:00
|
|
|
|
2017-12-29 10:45:37 -07:00
|
|
|
\sa wc_DeCompress
|
|
|
|
*/
|
2022-04-06 16:17:36 +01:00
|
|
|
int wc_Compress(byte* out, word32 outSz, const byte* in, word32 inSz, word32 flags);
|
2018-05-02 13:28:17 -06:00
|
|
|
|
2017-12-29 10:45:37 -07:00
|
|
|
/*!
|
|
|
|
\ingroup Compression
|
2018-06-27 16:22:12 -06:00
|
|
|
|
|
|
|
\brief This function decompresses the given compressed data using Huffman
|
2017-12-29 10:45:37 -07:00
|
|
|
coding and stores the output in out.
|
2018-06-27 16:22:12 -06:00
|
|
|
|
2020-01-10 11:45:51 -07:00
|
|
|
\return Success On successfully decompressing the input data, returns the
|
2017-12-29 10:45:37 -07:00
|
|
|
number of bytes stored in the output buffer
|
2018-06-27 16:22:12 -06:00
|
|
|
\return COMPRESS_INIT_E: Returned if there is an error initializing the
|
2017-12-29 10:45:37 -07:00
|
|
|
stream for compression
|
|
|
|
\return COMPRESS_E: Returned if an error occurs during compression
|
|
|
|
|
2018-06-27 16:22:12 -06:00
|
|
|
\param out pointer to the output buffer in which to store the decompressed
|
2017-12-29 10:45:37 -07:00
|
|
|
data
|
2018-06-27 16:22:12 -06:00
|
|
|
\param outSz size available in the output buffer for storage
|
2017-12-29 10:45:37 -07:00
|
|
|
\param in pointer to the buffer containing the message to decompress
|
|
|
|
\param inSz size of the input message to decompress
|
2018-06-27 16:22:12 -06:00
|
|
|
|
2017-12-29 10:45:37 -07:00
|
|
|
_Example_
|
|
|
|
\code
|
|
|
|
byte compressed[] = { // initialize compressed message };
|
2018-06-27 16:22:12 -06:00
|
|
|
byte decompressed[MAX_MESSAGE_SIZE];
|
2017-12-29 10:45:37 -07:00
|
|
|
|
2018-06-27 16:22:12 -06:00
|
|
|
if( wc_DeCompress(decompressed, sizeof(decompressed),
|
|
|
|
compressed, sizeof(compressed)) != 0 ) {
|
2017-12-29 10:45:37 -07:00
|
|
|
// error decompressing data
|
|
|
|
}
|
|
|
|
\endcode
|
2018-06-27 16:22:12 -06:00
|
|
|
|
2017-12-29 10:45:37 -07:00
|
|
|
\sa wc_Compress
|
|
|
|
*/
|
2022-04-06 16:17:36 +01:00
|
|
|
int wc_DeCompress(byte* out, word32 outSz, const byte* in, word32 inSz);
|