1
0

compress.hpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef _RAR_COMPRESS_
  2. #define _RAR_COMPRESS_
  3. // Combine pack and unpack constants to class to avoid polluting global
  4. // namespace with numerous short names.
  5. class PackDef
  6. {
  7. public:
  8. // Maximum LZ match length we can encode even for short distances.
  9. static const uint MAX_LZ_MATCH = 0x1001;
  10. // We increment LZ match length for longer distances, because shortest
  11. // matches are not allowed for them. Maximum length increment is 3
  12. // for distances larger than 256KB (0x40000). Here we define the maximum
  13. // incremented LZ match. Normally packer does not use it, but we must be
  14. // ready to process it in corrupt archives.
  15. static const uint MAX_INC_LZ_MATCH = MAX_LZ_MATCH + 3;
  16. static const uint MAX3_LZ_MATCH = 0x101; // Maximum match length for RAR v3.
  17. static const uint LOW_DIST_REP_COUNT = 16;
  18. static const uint NC = 306; /* alphabet = {0, 1, 2, ..., NC - 1} */
  19. static const uint DC = 64;
  20. static const uint LDC = 16;
  21. static const uint RC = 44;
  22. static const uint HUFF_TABLE_SIZE = NC + DC + RC + LDC;
  23. static const uint BC = 20;
  24. static const uint NC30 = 299; /* alphabet = {0, 1, 2, ..., NC - 1} */
  25. static const uint DC30 = 60;
  26. static const uint LDC30 = 17;
  27. static const uint RC30 = 28;
  28. static const uint BC30 = 20;
  29. static const uint HUFF_TABLE_SIZE30 = NC30 + DC30 + RC30 + LDC30;
  30. static const uint NC20 = 298; /* alphabet = {0, 1, 2, ..., NC - 1} */
  31. static const uint DC20 = 48;
  32. static const uint RC20 = 28;
  33. static const uint BC20 = 19;
  34. static const uint MC20 = 257;
  35. // Largest alphabet size among all values listed above.
  36. static const uint LARGEST_TABLE_SIZE = 306;
  37. enum {
  38. CODE_HUFFMAN, CODE_LZ, CODE_REPEATLZ, CODE_CACHELZ, CODE_STARTFILE,
  39. CODE_ENDFILE, CODE_FILTER, CODE_FILTERDATA
  40. };
  41. };
  42. enum FilterType {
  43. // These values must not be changed, because we use them directly
  44. // in RAR5 compression and decompression code.
  45. FILTER_DELTA=0, FILTER_E8, FILTER_E8E9, FILTER_ARM,
  46. FILTER_AUDIO, FILTER_RGB, FILTER_ITANIUM, FILTER_PPM, FILTER_NONE
  47. };
  48. #endif