lzostraw.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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/Library/lzostraw.h $*
  25. * *
  26. * $Author:: Greg_h $*
  27. * *
  28. * $Modtime:: 7/22/97 11:37a $*
  29. * *
  30. * $Revision:: 1 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef LZOSTRAW_H
  36. #define LZOSTRAW_H
  37. #include "straw.h"
  38. /*
  39. ** This class handles LZO compression/decompression to the data stream that is drawn through
  40. ** this class. Note that for compression, two internal buffers are required. For decompression
  41. ** only one buffer is required. This changes the memory footprint of this class depending on
  42. ** the process desired.
  43. */
  44. class LZOStraw : public Straw
  45. {
  46. public:
  47. typedef enum CompControl {
  48. COMPRESS,
  49. DECOMPRESS
  50. } CompControl;
  51. LZOStraw(CompControl control, int blocksize=1024*8);
  52. virtual ~LZOStraw(void);
  53. virtual int Get(void * source, int slen);
  54. private:
  55. /*
  56. ** This tells the pipe if it should be decompressing or compressing the data stream.
  57. */
  58. CompControl Control;
  59. /*
  60. ** The number of bytes accumulated into the staging buffer.
  61. */
  62. int Counter;
  63. /*
  64. ** Pointer to the working buffer that compression/decompression will use.
  65. */
  66. char * Buffer;
  67. char * Buffer2;
  68. /*
  69. ** The working block size. Data will be compressed in chunks of this size.
  70. */
  71. int BlockSize;
  72. /*
  73. ** Probably dont need this anymore as LZO decompresses into a staging buffer.
  74. */
  75. int SafetyMargin;
  76. /*
  77. ** Each block has a header of this format.
  78. */
  79. struct {
  80. unsigned short CompCount; // Size of data block (compressed).
  81. unsigned short UncompCount; // Bytes of uncompressed data it represents.
  82. } BlockHeader;
  83. LZOStraw(LZOStraw & rvalue);
  84. LZOStraw & operator = (LZOStraw const & pipe);
  85. };
  86. #endif