1
0

compress.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*!
  2. \ingroup Compression
  3. \brief This function compresses the given input data using Huffman coding
  4. and stores the output in out. Note that the output buffer should still be
  5. larger than the input buffer because there exists a certain input for
  6. which there will be no compression possible, which will still require a
  7. lookup table. It is recommended that one allocate srcSz + 0.1% + 12 for
  8. the output buffer.
  9. \return On successfully compressing the input data, returns the number
  10. of bytes stored in the output buffer
  11. \return COMPRESS_INIT_E Returned if there is an error initializing the
  12. stream for compression
  13. \return COMPRESS_E Returned if an error occurs during compression
  14. \param out pointer to the output buffer in which to store the compressed
  15. data
  16. \param outSz size available in the output buffer for storage
  17. \param in pointer to the buffer containing the message to compress
  18. \param inSz size of the input message to compress
  19. \param flags flags to control how compression operates. Use 0 for normal
  20. decompression
  21. _Example_
  22. \code
  23. byte message[] = { // initialize text to compress };
  24. byte compressed[(sizeof(message) + sizeof(message) * .001 + 12 )];
  25. // Recommends at least srcSz + .1% + 12
  26. if( wc_Compress(compressed, sizeof(compressed), message, sizeof(message),
  27. 0) != 0){
  28. // error compressing data
  29. }
  30. \endcode
  31. \sa wc_DeCompress
  32. */
  33. int wc_Compress(byte* out, word32 outSz, const byte* in, word32 inSz, word32 flags);
  34. /*!
  35. \ingroup Compression
  36. \brief This function decompresses the given compressed data using Huffman
  37. coding and stores the output in out.
  38. \return Success On successfully decompressing the input data, returns the
  39. number of bytes stored in the output buffer
  40. \return COMPRESS_INIT_E: Returned if there is an error initializing the
  41. stream for compression
  42. \return COMPRESS_E: Returned if an error occurs during compression
  43. \param out pointer to the output buffer in which to store the decompressed
  44. data
  45. \param outSz size available in the output buffer for storage
  46. \param in pointer to the buffer containing the message to decompress
  47. \param inSz size of the input message to decompress
  48. _Example_
  49. \code
  50. byte compressed[] = { // initialize compressed message };
  51. byte decompressed[MAX_MESSAGE_SIZE];
  52. if( wc_DeCompress(decompressed, sizeof(decompressed),
  53. compressed, sizeof(compressed)) != 0 ) {
  54. // error decompressing data
  55. }
  56. \endcode
  57. \sa wc_Compress
  58. */
  59. int wc_DeCompress(byte* out, word32 outSz, const byte* in, word32 inSz);