simple_encoder.c 914 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // SPDX-License-Identifier: 0BSD
  2. ///////////////////////////////////////////////////////////////////////////////
  3. //
  4. /// \file simple_encoder.c
  5. /// \brief Properties encoder for simple filters
  6. //
  7. // Author: Lasse Collin
  8. //
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #include "simple_encoder.h"
  11. extern lzma_ret
  12. lzma_simple_props_size(uint32_t *size, const void *options)
  13. {
  14. const lzma_options_bcj *const opt = options;
  15. *size = (opt == NULL || opt->start_offset == 0) ? 0 : 4;
  16. return LZMA_OK;
  17. }
  18. extern lzma_ret
  19. lzma_simple_props_encode(const void *options, uint8_t *out)
  20. {
  21. const lzma_options_bcj *const opt = options;
  22. // The default start offset is zero, so we don't need to store any
  23. // options unless the start offset is non-zero.
  24. if (opt == NULL || opt->start_offset == 0)
  25. return LZMA_OK;
  26. write32le(out, opt->start_offset);
  27. return LZMA_OK;
  28. }