rle.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) 2020 Actions Technology Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef __COMPRESSION_RLE_H__
  7. #define __COMPRESSION_RLE_H__
  8. #include <stdint.h>
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. /**
  13. * @brief RLE encode
  14. *
  15. * @param out_buf pointer to encoded output buffer
  16. * @param out_size size of output buffer in bytes
  17. * @param in_buf pointer to input buffer
  18. * @param in_count size of input buffer in elements
  19. * @param size size of each element in bytes
  20. *
  21. * @retval number of bytes actually encoded if out_buf is not NULL
  22. * @retval total encoded bytes if out_buf is NULL
  23. */
  24. int rle_compress(const uint8_t* in_buf, uint8_t * out_buf, size_t in_count, size_t out_size, size_t size);
  25. /**
  26. * @brief RLE decode
  27. *
  28. * @param out_buf pointer to output buffer
  29. * @param out_count size of output buffer in elements
  30. * @param in_buf pointer to encoded input buffer
  31. * @param in_size size of input buffer in bytes
  32. * @param size size of each element in bytes
  33. *
  34. * @retval number of bytes actually decoded if out_buf is not NULL
  35. * @retval total decoded bytes if out_buf is NULL
  36. */
  37. int rle_decompress(const uint8_t * in_buf, uint8_t * out_buf, int in_size, int out_count, size_t size);
  38. #ifdef __cplusplus
  39. }
  40. #endif
  41. #endif /* __COMPRESSION_RLE_H__ */