simple_encoder.c 983 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. /// \file simple_encoder.c
  4. /// \brief Properties encoder for 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. #include "simple_encoder.h"
  13. extern lzma_ret
  14. lzma_simple_props_size(uint32_t *size, const void *options)
  15. {
  16. const lzma_options_bcj *const opt = options;
  17. *size = (opt == NULL || opt->start_offset == 0) ? 0 : 4;
  18. return LZMA_OK;
  19. }
  20. extern lzma_ret
  21. lzma_simple_props_encode(const void *options, uint8_t *out)
  22. {
  23. const lzma_options_bcj *const opt = options;
  24. // The default start offset is zero, so we don't need to store any
  25. // options unless the start offset is non-zero.
  26. if (opt == NULL || opt->start_offset == 0)
  27. return LZMA_OK;
  28. write32le(out, opt->start_offset);
  29. return LZMA_OK;
  30. }