lzo.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Command & Conquer *
  23. * *
  24. * $Archive:: /Commando/Code/wwlib/lzo.h $*
  25. * *
  26. * $Author:: Greg_h $*
  27. * *
  28. * $Modtime:: 7/19/99 3:35p $*
  29. * *
  30. * $Revision:: 3 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef _LZO_H
  36. #define _LZO_H
  37. #include "lzoconf.h"
  38. #include "lzo1x.h"
  39. // Macros.
  40. // Maximum size of any LZO compressed chunk expessed in terms of maximum size
  41. // of UNcompressed chunk. NOTE: LZO needs an additional 16 bytes per uncompressed K.
  42. // Note: SKB took this from lzo.h in lol3 code.
  43. //
  44. // (gth) The buffer that you compress to should be the size define by
  45. // LZO_BUFFER_SIZE(uncompressed_size). Also, the work buffer should be of
  46. // size: LZO1X_MEM_COMPRESS which is defined in lzo1x.h.
  47. #define LZO_BUFFER_SIZE(s) ((s) + ((((s) / 0x400) + 1) * 16))
  48. int lzo1x_1_compress ( const lzo_byte *in,
  49. lzo_uint in_len,
  50. lzo_byte *out,
  51. lzo_uint *out_len,
  52. lzo_voidp wrkmem);
  53. int lzo1x_decompress ( const lzo_byte *in,
  54. lzo_uint in_len,
  55. lzo_byte *out,
  56. lzo_uint *out_len,
  57. lzo_voidp);
  58. //
  59. // LZOCompressor
  60. // Simply wraps the 'C' style lzo compression and decompression functions and
  61. // hides the work buffer. So you dont have to worry about the work buffer but
  62. // you do have to manage the compression buffer being large enough to hold the
  63. // worst case compression: LZO_BUFFER_SIZE(uncompressed_size).
  64. //
  65. class LZOCompressor
  66. {
  67. public:
  68. static int Compress
  69. (
  70. const lzo_byte * in,
  71. lzo_uint in_len,
  72. lzo_byte * out,
  73. lzo_uint * out_len
  74. );
  75. static int Decompress
  76. (
  77. const lzo_byte * in,
  78. lzo_uint in_len,
  79. lzo_byte * out,
  80. lzo_uint * out_len
  81. );
  82. private:
  83. static lzo_byte WorkBuffer[LZO1X_MEM_COMPRESS + 1];
  84. static lzo_byte * EOWorkBuffer;
  85. };
  86. #endif