lzmar.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef __LZMAR_H__
  13. #define __LZMAR_H__
  14. #include "osi_compiler.h"
  15. #include <stddef.h>
  16. OSI_EXTERN_C_BEGIN
  17. typedef struct
  18. {
  19. uint32_t data_size; // size in bytes
  20. uint16_t block_size; // size in 1KB bytes
  21. uint8_t dict_size; // size in 1KB bytes
  22. uint8_t prop; // the property byte
  23. } lzmaFileHeader_t;
  24. // Software LZMAr compress and decompress.
  25. //
  26. // This compress and decompress can match hardware LZMA. It is a modified
  27. // LZMA. And it is the reason of "r".
  28. //
  29. // These APIs aren'y optimized for memory usage and performace. At compress,
  30. // it will allocate 245,904 + 65,536 + 1,536 + 1,536 + 536,584 bytes.
  31. // Also, the decompress is not thread safe.
  32. /**
  33. * \brief compress data to blocked compressed output
  34. *
  35. * The output buffer should be larger enough to hole the compressed data.
  36. *
  37. * \param input input data
  38. * \param insize input data size
  39. * \param output output buffer
  40. * \param outsize output buffer size
  41. * \parem block_size compress block size
  42. * \return
  43. * - compressed data size
  44. * - negative on error
  45. */
  46. int lzmarCompress(const void *input, size_t insize, void *output, size_t outsize,
  47. unsigned block_size);
  48. /**
  49. * \brief decompress blocked compressed data
  50. *
  51. * The output buffer should be larger enough to hole the decompressed data.
  52. *
  53. * \param input input data
  54. * \param insize input data size
  55. * \param output output buffer
  56. * \param outsize output buffer size
  57. * \return
  58. * - decompressed data size
  59. * - negative on error
  60. */
  61. int lzmarDecompress(const void *input, size_t insize, void *output, size_t outsize);
  62. /**
  63. * \brief get blocked compressed data size
  64. *
  65. * \param input input data
  66. * \return
  67. * - decompressed data size
  68. * - negative on error
  69. */
  70. int lzmarDataSize(const void *input);
  71. int lzmarCompress4Pieces(const void *input, size_t insize, void *output, size_t outsize,
  72. unsigned block_size, uint8_t *prop);
  73. OSI_EXTERN_C_END
  74. #endif