CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

LZWSTRAW.H (4127B)


      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 
      9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 
     10 // in the hope that it will be useful, but with permitted additional restrictions 
     11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 
     12 // distributed with this program. You should have received a copy of the 
     13 // GNU General Public License along with permitted additional restrictions 
     14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
     15 
     16 /* $Header: /CounterStrike/LZWSTRAW.H 1     3/03/97 10:25a Joe_bostic $ */
     17 /***********************************************************************************************
     18  ***              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               ***
     19  ***********************************************************************************************
     20  *                                                                                             *
     21  *                 Project Name : Command & Conquer                                            *
     22  *                                                                                             *
     23  *                    File Name : LZWSTRAW.H                                                   *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : 07/02/96                                                     *
     28  *                                                                                             *
     29  *                  Last Update : July 2, 1996 [JLB]                                           *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     34 
     35 
     36 #ifndef LZWSTRAW_H
     37 #define LZWSTRAW_H
     38 
     39 
     40 #include	"straw.h"
     41 
     42 /*
     43 **	This class handles LZW compression/decompression to the data stream that is drawn through
     44 **	this class. Note that for compression, two internal buffers are required. For decompression
     45 **	only one buffer is required. This changes the memory footprint of this class depending on
     46 **	the process desired.
     47 */
     48 class LZWStraw : public Straw
     49 {
     50 	public:
     51 		typedef enum CompControl {
     52 			COMPRESS,
     53 			DECOMPRESS
     54 		} CompControl;
     55 
     56 		LZWStraw(CompControl control, int blocksize=1024*8);
     57 		virtual ~LZWStraw(void);
     58 
     59 		virtual int Get(void * source, int slen);
     60 
     61 	private:
     62 
     63 		/*
     64 		**	This tells the pipe if it should be decompressing or compressing the data stream.
     65 		*/
     66 		CompControl Control;
     67 
     68 		/*
     69 		**	The number of bytes accumulated into the staging buffer.
     70 		*/
     71 		int Counter;
     72 
     73 		/*
     74 		**	Pointer to the working buffer that compression/decompression will use.
     75 		*/
     76 		char * Buffer;
     77 		char * Buffer2;
     78 
     79 		/*
     80 		**	The working block size. Data will be compressed in chunks of this size.
     81 		*/
     82 		int BlockSize;
     83 
     84 		/*
     85 		**	LZW compression requires a safety margin when decompressing over itself. This
     86 		**	margin is only for the worst case situation (very rare).
     87 		*/
     88 		int SafetyMargin;
     89 
     90 		/*
     91 		**	Each block has a header of this format.
     92 		*/
     93 		struct {
     94 			unsigned short CompCount;		// Size of data block (compressed).
     95 			unsigned short UncompCount;	// Bytes of uncompressed data it represents.
     96 		} BlockHeader;
     97 
     98 		LZWStraw(LZWStraw & rvalue);
     99 		LZWStraw & operator = (LZWStraw const & pipe);
    100 };
    101 
    102 
    103 #endif