simple_private.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 {
  16. /// Next filter in the chain
  17. lzma_next_coder next;
  18. /// True if the next coder in the chain has returned LZMA_STREAM_END.
  19. bool end_was_reached;
  20. /// True if filter() should encode the data; false to decode.
  21. /// Currently all simple filters use the same function for encoding
  22. /// and decoding, because the difference between encoders and decoders
  23. /// is very small.
  24. bool is_encoder;
  25. /// Pointer to filter-specific function, which does
  26. /// the actual filtering.
  27. size_t (*filter)(void *simple, uint32_t now_pos,
  28. bool is_encoder, uint8_t *buffer, size_t size);
  29. /// Pointer to filter-specific data, or NULL if filter doesn't need
  30. /// any extra data.
  31. void *simple;
  32. /// The lowest 32 bits of the current position in the data. Most
  33. /// filters need this to do conversions between absolute and relative
  34. /// addresses.
  35. uint32_t now_pos;
  36. /// Size of the memory allocated for the buffer.
  37. size_t allocated;
  38. /// Flushing position in the temporary buffer. buffer[pos] is the
  39. /// next byte to be copied to out[].
  40. size_t pos;
  41. /// buffer[filtered] is the first unfiltered byte. When pos is smaller
  42. /// than filtered, there is unflushed filtered data in the buffer.
  43. size_t filtered;
  44. /// Total number of bytes (both filtered and unfiltered) currently
  45. /// in the temporary buffer.
  46. size_t size;
  47. /// Temporary buffer
  48. uint8_t buffer[];
  49. } lzma_simple_coder;
  50. extern lzma_ret lzma_simple_coder_init(lzma_next_coder *next,
  51. const lzma_allocator *allocator,
  52. const lzma_filter_info *filters,
  53. size_t (*filter)(void *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