LZOSTRAW.H 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/LZoSTRAW.H 1 3/03/97 10:25a Joe_bostic $ */
  15. /***********************************************************************************************
  16. *** 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 ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : LZOSTRAW.H *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : 07/02/96 *
  26. * *
  27. * Last Update : July 2, 1996 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #ifndef LZOSTRAW_H
  33. #define LZOSTRAW_H
  34. #include "straw.h"
  35. /*
  36. ** This class handles LZO compression/decompression to the data stream that is drawn through
  37. ** this class. Note that for compression, two internal buffers are required. For decompression
  38. ** only one buffer is required. This changes the memory footprint of this class depending on
  39. ** the process desired.
  40. */
  41. class LZOStraw : public Straw
  42. {
  43. public:
  44. typedef enum CompControl {
  45. COMPRESS,
  46. DECOMPRESS
  47. } CompControl;
  48. LZOStraw(CompControl control, int blocksize=1024*8);
  49. virtual ~LZOStraw(void);
  50. virtual int Get(void * source, int slen);
  51. private:
  52. /*
  53. ** This tells the pipe if it should be decompressing or compressing the data stream.
  54. */
  55. CompControl Control;
  56. /*
  57. ** The number of bytes accumulated into the staging buffer.
  58. */
  59. int Counter;
  60. /*
  61. ** Pointer to the working buffer that compression/decompression will use.
  62. */
  63. char * Buffer;
  64. char * Buffer2;
  65. /*
  66. ** The working block size. Data will be compressed in chunks of this size.
  67. */
  68. int BlockSize;
  69. /*
  70. ** Probably dont need this anymore as LZO decompresses into a staging buffer.
  71. */
  72. int SafetyMargin;
  73. /*
  74. ** Each block has a header of this format.
  75. */
  76. struct {
  77. unsigned short CompCount; // Size of data block (compressed).
  78. unsigned short UncompCount; // Bytes of uncompressed data it represents.
  79. } BlockHeader;
  80. LZOStraw(LZOStraw & rvalue);
  81. LZOStraw & operator = (LZOStraw const & pipe);
  82. };
  83. #endif