/* =========================================================================== IceTech GPL Source Code Copyright (C) 2026 Justin Marshall This file is part of the IceTech GPL Source Code (?IceTech Source Code?). IceTech Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. IceTech Source Code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with IceTech Source Code. If not, see . In addition, the IceTech Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the IceTech Source Code. If not, please request a copy in writing from id Software at the address below. If you have questions concerning this license or the applicable additional terms, you may contact in writing Justin Marshall, justinmarshall20@gmail.com =========================================================================== */ #ifndef __COMPRESSOR_H__ #define __COMPRESSOR_H__ /* =============================================================================== idCompressor is a layer ontop of idFile which provides lossless data compression. The compressor can be used as a regular file and multiple compressors can be stacked ontop of each other. =============================================================================== */ class idCompressor : public idFile { public: // compressor allocation static idCompressor* AllocNoCompression(void); static idCompressor* AllocBitStream(void); static idCompressor* AllocRunLength(void); static idCompressor* AllocRunLength_ZeroBased(void); static idCompressor* AllocHuffman(void); static idCompressor* AllocArithmetic(void); static idCompressor* AllocLZSS(void); static idCompressor* AllocLZSS_WordAligned(void); static idCompressor* AllocLZW(void); // initialization virtual void Init(idFile* f, bool compress, int wordLength) = 0; virtual void FinishCompress(void) = 0; virtual float GetCompressionRatio(void) const = 0; // common idFile interface virtual const char* GetName(void) = 0; virtual const char* GetFullPath(void) = 0; virtual int Read(void* outData, int outLength) = 0; virtual int Write(const void* inData, int inLength) = 0; virtual int Length(void) = 0; #ifdef QUAKE4 virtual unsigned int Timestamp(void) = 0; #else virtual ID_TIME_T Timestamp(void) = 0; #endif virtual int Tell(void) = 0; virtual void ForceFlush(void) = 0; virtual void Flush(void) = 0; virtual int Seek(long offset, fsOrigin_t origin) = 0; #ifdef QUAKE4 // Quake 4's idFile has these as pure virtuals. Doom 3 normally got these // from idFile defaults, so provide compressor-level implementations once // instead of adding duplicates to every compressor subclass. virtual void Rewind(void); virtual int Printf(const char* fmt, ...); virtual int VPrintf(const char* fmt, va_list args); virtual int WriteFloatString(const char* fmt, ...); virtual int ReadInt(int& value); virtual int ReadUnsignedInt(unsigned int& value); virtual int ReadShort(short& value); virtual int ReadUnsignedShort(unsigned short& value); virtual int ReadChar(char& value); virtual int ReadUnsignedChar(unsigned char& value); virtual int ReadFloat(float& value); virtual int ReadBool(bool& value); virtual int ReadString(idStr& string); virtual int ReadVec2(idVec2& vec); virtual int ReadVec3(idVec3& vec); virtual int ReadVec4(idVec4& vec); virtual int ReadVec5(idVec5& vec); virtual int ReadVec6(idVec6& vec); virtual int ReadMat3(idMat3& mat); virtual int ReadBounds(idBounds& bounds); virtual int WriteInt(const int value); virtual int WriteUnsignedInt(const unsigned int value); virtual int WriteShort(const short value); virtual int WriteUnsignedShort(unsigned short value); virtual int WriteChar(const char value); virtual int WriteUnsignedChar(const unsigned char value); virtual int WriteFloat(const float value); virtual int WriteBool(const bool value); virtual int WriteString(const char* string); virtual int WriteVec2(const idVec2& vec); virtual int WriteVec3(const idVec3& vec); virtual int WriteVec4(const idVec4& vec); virtual int WriteVec5(const idVec5& vec); virtual int WriteVec6(const idVec6& vec); virtual int WriteMat3(const idMat3& mat); virtual int WriteBounds(const idBounds& bounds); virtual void WriteNumericStructArray(int numStructs, int structMembers[], int structSize, byte* data, const char* format); virtual void WriteSyncId(void); virtual void ReadSyncId(const char* fmt, const char* name); #endif }; #endif /* !__COMPRESSOR_H__ */