simple_encoder.c 993 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. unaligned_write32le(out, opt->start_offset);
  29. return LZMA_OK;
  30. }