simple_private.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. /// \file simple_private.h
  4. /// \brief Private definitions for so called simple filters
  5. //
  6. // Author: Lasse Collin
  7. //
  8. // This file has been put into the public domain.
  9. // You can do whatever you want with this file.
  10. //
  11. ///////////////////////////////////////////////////////////////////////////////
  12. #ifndef LZMA_SIMPLE_PRIVATE_H
  13. #define LZMA_SIMPLE_PRIVATE_H
  14. #include "simple_coder.h"
  15. typedef struct lzma_simple_s lzma_simple;
  16. struct lzma_coder_s {
  17. /// Next filter in the chain
  18. lzma_next_coder next;
  19. /// True if the next coder in the chain has returned LZMA_STREAM_END.
  20. bool end_was_reached;
  21. /// True if filter() should encode the data; false to decode.
  22. /// Currently all simple filters use the same function for encoding
  23. /// and decoding, because the difference between encoders and decoders
  24. /// is very small.
  25. bool is_encoder;
  26. /// Pointer to filter-specific function, which does
  27. /// the actual filtering.
  28. size_t (*filter)(lzma_simple *simple, uint32_t now_pos,
  29. bool is_encoder, uint8_t *buffer, size_t size);
  30. /// Pointer to filter-specific data, or NULL if filter doesn't need
  31. /// any extra data.
  32. lzma_simple *simple;
  33. /// The lowest 32 bits of the current position in the data. Most
  34. /// filters need this to do conversions between absolute and relative
  35. /// addresses.
  36. uint32_t now_pos;
  37. /// Size of the memory allocated for the buffer.
  38. size_t allocated;
  39. /// Flushing position in the temporary buffer. buffer[pos] is the
  40. /// next byte to be copied to out[].
  41. size_t pos;
  42. /// buffer[filtered] is the first unfiltered byte. When pos is smaller
  43. /// than filtered, there is unflushed filtered data in the buffer.
  44. size_t filtered;
  45. /// Total number of bytes (both filtered and unfiltered) currently
  46. /// in the temporary buffer.
  47. size_t size;
  48. /// Temporary buffer
  49. uint8_t buffer[];
  50. };
  51. extern lzma_ret lzma_simple_coder_init(lzma_next_coder *next,
  52. lzma_allocator *allocator, const lzma_filter_info *filters,
  53. size_t (*filter)(lzma_simple *simple, uint32_t now_pos,
  54. bool is_encoder, uint8_t *buffer, size_t size),
  55. size_t simple_size, size_t unfiltered_max,
  56. uint32_t alignment, bool is_encoder);
  57. #endif