lh5_decoder.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. Copyright (c) 2011, 2012, Simon Howard
  3. Permission to use, copy, modify, and/or distribute this software
  4. for any purpose with or without fee is hereby granted, provided
  5. that the above copyright notice and this permission notice appear
  6. in all copies.
  7. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  8. WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  9. WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  10. AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
  11. CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  12. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  13. NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. //
  17. // Decoder for the -lh5- algorithm.
  18. //
  19. // This is the "new" algorithm that appeared in LHA v2, replacing
  20. // the older -lh1-. -lh4- seems to be identical to -lh5-.
  21. //
  22. // 16 KiB history ring buffer:
  23. #define HISTORY_BITS 14 /* 2^14 = 16384 */
  24. // Number of bits to encode HISTORY_BITS:
  25. #define OFFSET_BITS 4
  26. // Name of the variable for the encoder:
  27. #define DECODER_NAME lha_lh5_decoder
  28. // Generate a second decoder for lh4 that just has a different
  29. // block size.
  30. #define DECODER2_NAME lha_lh4_decoder
  31. // The actual algorithm code is contained in lh_new_decoder.c, which
  32. // acts as a template for -lh4-, -lh5-, -lh6- and -lh7-.
  33. #include "lh_new_decoder.c"