diff options
author | Max Horn | 2008-11-07 09:46:12 +0000 |
---|---|---|
committer | Max Horn | 2008-11-07 09:46:12 +0000 |
commit | 060aa5b002a7c1808e6e54ab5585a40a18c5a0b4 (patch) | |
tree | 6b32136e666aa2fd1b78070f8bcdc0eef3e4c846 /common/unarj.h | |
parent | 8baedea4d49a758e2ccaa78ed8a0c4ff36e3464c (diff) | |
download | scummvm-rg350-060aa5b002a7c1808e6e54ab5585a40a18c5a0b4.tar.gz scummvm-rg350-060aa5b002a7c1808e6e54ab5585a40a18c5a0b4.tar.bz2 scummvm-rg350-060aa5b002a7c1808e6e54ab5585a40a18c5a0b4.zip |
Refactoring the Arj decoder code, phase 1
svn-id: r34922
Diffstat (limited to 'common/unarj.h')
-rw-r--r-- | common/unarj.h | 102 |
1 files changed, 4 insertions, 98 deletions
diff --git a/common/unarj.h b/common/unarj.h index d16d748ad3..4e9750609e 100644 --- a/common/unarj.h +++ b/common/unarj.h @@ -31,57 +31,8 @@ namespace Common { -#define ARJ_UCHAR_MAX 255 -#define ARJ_CHAR_BIT 8 - -#define ARJ_COMMENT_MAX 2048 -#define ARJ_FILENAME_MAX 512 - -#define ARJ_CODE_BIT 16 -#define ARJ_THRESHOLD 3 -#define ARJ_DICSIZ 26624 -#define ARJ_FDICSIZ ARJ_DICSIZ -#define ARJ_MAXDICBIT 16 -#define ARJ_MAXMATCH 256 -#define ARJ_NC (ARJ_UCHAR_MAX + ARJ_MAXMATCH + 2 - ARJ_THRESHOLD) -#define ARJ_NP (ARJ_MAXDICBIT + 1) -#define ARJ_NT (ARJ_CODE_BIT + 3) - -#if ARJ_NT > ARJ_NP -#define ARJ_NPT ARJ_NT -#else -#define ARJ_NPT ARJ_NP -#endif - -#define ARJ_CTABLESIZE 4096 -#define ARJ_PTABLESIZE 256 - - -struct ArjHeader { - int32 pos; - uint16 id; - uint16 headerSize; - // - byte firstHdrSize; - byte nbr; - byte xNbr; - byte hostOs; - byte flags; - byte method; - byte fileType; - byte pad; - uint32 timeStamp; - int32 compSize; - int32 origSize; - uint32 fileCRC; - uint16 entryPos; - uint16 fileMode; - uint16 hostData; - char filename[ARJ_FILENAME_MAX]; - char comment[ARJ_COMMENT_MAX]; - - uint32 headerCrc; -}; +struct ArjHeader; +class ArjDecoder; typedef HashMap<String, int, IgnoreCase_Hash, IgnoreCase_EqualTo> ArjFilesMap; @@ -111,58 +62,13 @@ private: Array<ArjHeader *> _headers; ArjFilesMap _fileMap; StringMap _archMap; - ReadStream *_stream; + byte *_uncompressedData; - byte *_compressedData; - MemoryWriteStream *_outstream; - MemoryReadStream *_compressed; SeekableReadStream *_uncompressed; bool _isOpen; - - int32 findHeader(void); - ArjHeader *readHeader(); - - void decode(); - void decode_f(); - - uint16 _bitbuf; - uint16 _bytebuf; - int32 _compsize; - int32 _origsize; - byte _subbitbuf; - int _bitcount; - - void init_getbits(); - void fillbuf(int n); - uint16 getbits(int n); - - void make_table(int nchar, byte *bitlen, int tablebits, uint16 *table, int tablesize); - void read_pt_len(int nn, int nbit, int i_special); - void read_c_len(void); - uint16 decode_c(void); - uint16 decode_p(void); - void decode_start(void); - int16 decode_ptr(void); - int16 decode_len(void); - -private: - byte _ntext[ARJ_FDICSIZ]; - - int16 _getlen; - int16 _getbuf; - - uint16 _left[2 * ARJ_NC - 1]; - uint16 _right[2 * ARJ_NC - 1]; - byte _c_len[ARJ_NC]; - byte _pt_len[ARJ_NPT]; - - uint16 _c_table[ARJ_CTABLESIZE]; - uint16 _pt_table[ARJ_PTABLESIZE]; - uint16 _blocksize; - - + ArjDecoder *_decoder; }; } // End of namespace Common |