"L. Spiro Engine"
Classes | Typedefs | Functions | Variables

lsc Namespace Reference

Classes

class  CLzwDecodingDict
 A dictionary for decoding an LZW bytestream. More...
class  CLzwEncodingDict
 A dictionary for the encoding of a bytestream using the LZW algorithm. More...
class  CMisc
 Various types of specialized compression routines. More...
class  CZLib
 A primitive and light-weight implementation of a zlib inflation routine. More...

Typedefs

typedef lsstd::CBitStream Parent

Functions

LSVOID LSE_CALL SetAllocator (CAllocator *_paAllocator)
CAllocator *LSE_CALL GetAllocator ()
virtual LSVOID *LSE_CALL ReAlloc (LSVOID *_pvOriginal, LSUINT32 _ui32Total) const
virtual LSVOID LSE_CALL Free (LSVOID *_pvOriginal) const
LSVOID LSE_CALL SetAllocator (CStdAllocator *_psaAllocator)
LSUINT32 LSE_CALL Decode (const CBitStream &_bsStream, LSUINT32 _ui32DictionaryStartingSize, LSUINT32 _ui32MaxBits, lsstd::IStream &_sStream, LSBOOL _bResetDictionary=false)
LSUINT32 LSE_CALL Encode (const LSUINT8 *_pui8Bytes, LSUINT64 _ui64Size, LSUINT32 _ui32DictionaryStartingSize, LSUINT32 _ui32MaxBits, CBitStream &_bsStream, LSBOOL _bResetDictionary=false, LSUINT32 _ui32PrevBits=0UL, LSUINT32 _ui32MaxSize=~0UL)
LSBOOL LSE_CALL EndStream (CBitStream &_bsStream) const

Variables

__pad0__
CAllocator * m_paAllocator
CLzwDecodingDict m_lddDict
CLzwEncodingDict m_ledDict

Detailed Description

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Extends the lsstd::CBitStream class with memory-manager functionality.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Decodes a bitstream previously encoded with CLzwEncoder::Encode().

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: When decoding, the dictionary format for dictionary entries in the LZW compression scheme are different from when encoding. The codes are referenced only by code during decompression, allowing us to store the entries linearly during decompression. Our loop-up and usage functiosn for the codes are different from the ones used during encryption.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Encodes a stream of bytes into an LZW compressed stream of bits.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Description: When encoding bytes, the dictionary for the LZW algorithm is stored differently from when the bytes are being decoded. During encryption, codes are referenced via (code+char) combination which requires a hash look-up. For this reason, we cannot store the codes in such a way that index = code. During decoding, however, codes are referenced only by code, so we are able to store the codes linearly such that index = code. This saves space over the encoding algorithm and gives us cause to keep the two dictionaries separate. The dictionary is created with a maximum size at the beginning, which depends on the maximum number of bits a code may have. This class can output variable-sized codes or predefined-sized codes as per the desires of the user. Variable-sized codes simply means that the smallest number of bits needed to access any code in the dictionary are output instead of using a fixed size such as 15 bits for every code. This is the typical method for encoding.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: Various types of specialized compression routines. Data often gets compressed better when routines are specialized towards that type of data. For example, if a normal is assumed to be unit-length, only 65 bits are needed to hold it, instead of 96. An array of index data usually starts with low numbers and gradually builds into higher numbers. Only a few bits of data are needed to hold the first several numbers.

Copyright L. Spiro 2011 All rights reserved.

Written by: Shawn (L. Spiro) Wilcoxen

This code may not be sold or traded for any personal gain without express written consent. You may use this code in your own projects and modify it to suit your needs as long as this disclaimer remains intact. You may not take credit for having written this code.

Description: A primitive and light-weight implementation of a zlib inflation routine. This class cannot be used to compress/deflate data.


Function Documentation

LSUINT32 LSE_CALL lsc::Decode ( const CBitStream &  _bsStream,
LSUINT32  _ui32DictionaryStartingSize,
LSUINT32  _ui32MaxBits,
lsstd::IStream _sStream,
LSBOOL  _bResetDictionary = false 
)

Decode raw bytes of LZW compressed data.

Parameters:
_bsStreamBitstream containing data compressed with the LZW algorithm.
_ui32DictionaryStartingSizeStarting size of the dictionary.
_ui32MaxBitsMaximum bits possible in the dictionary.
_sStreamThe stream to hold the decoded bytes.
_bResetDictionaryIf true, the dictionary is reset for the decoding of this chunk of bytes. This is optional so as to allow breaking up the decoding into multiple chunks.
Returns:
Returns the number of bits needed to read the next code from the input buffer. This can be used in a subsequent call to Decode() to continue decoding data over several chunks. If 0 is returned, an error occurred.
LSUINT32 LSE_CALL lsc::Encode ( const LSUINT8 *  _pui8Bytes,
LSUINT64  _ui64Size,
LSUINT32  _ui32DictionaryStartingSize,
LSUINT32  _ui32MaxBits,
CBitStream &  _bsStream,
LSBOOL  _bResetDictionary = false,
LSUINT32  _ui32PrevBits = 0UL,
LSUINT32  _ui32MaxSize = ~0UL 
)

Encode an array of bytes. The encoded data is output at the current position in the given bitstream. This allows multiple encodings to be packed together into the same stream.

Parameters:
_pui8BytesPointer to the bytes to encode.
_ui64SizeSize of the buffer to which _pui8Bytes points.
_ui32DictionaryStartingSizeStarting size of the dictionary.
_ui32MaxBitsMaximum bits possible in the dictionary.
_bsStreamStream to which the compressed bits are to be written.
_bResetDictionaryIf true, the dictionary will be reset and the first code output to the bitstream will be a dictionary-reset code of _ui32PrevBits bits.
_ui32PrevBitsIf bits were already compressed to _bsStream, this informs this function of the size of the next command, in bits, that would be read from the stream if decompressing. This is required if _bsStream is not empty.
_ui32MaxSizeSize at which to stop compression. If the size of the compressed data exceeds this amount then compression is ended.
Returns:
Returns the size of the next command that would be written to _bsStream if compression were to continue. This can be used in a subsequent call to Encode(). On error, 0UL is returned.
LSBOOL LSE_CALL lsc::EndStream ( CBitStream &  _bsStream) const

Append a bit stream with a stream-end code using the current dictionary. If the dictionary is empty the function fails.

Parameters:
_bsStreamThe stream to which to append the end-of-stream code.
Returns:
Returns true if there is a dictionary and the append succeeded.
virtual LSVOID LSE_CALL lsc::Free ( LSVOID *  _pvOriginal) const [protected, virtual]

Free bytes. Overrides the base definition to allow usage of our allocator, if not NULL.

Parameters:
_pvOriginalPointer to the data, allocated with ReAlloc() to free.
CAllocator* LSE_CALL lsc::GetAllocator ( )

Get our allocator.

Returns:
Returns the allocator assigned to this object.

Gets our allocator.

Returns:
Returns our allocator.

Get our allocator.

Returns:
Returns a pointer to the allocator used by this object.
virtual LSVOID* LSE_CALL lsc::ReAlloc ( LSVOID *  _pvOriginal,
LSUINT32  _ui32Total 
) const [protected, virtual]

Re-allocate bytes. Overrides the base definition to allow usage of our allocator, if not NULL.

Parameters:
_pvOriginalAddress to re-alloate. Pass NULL to allocate new data.
_ui32TotalTotal number of bytes to allocate.
Returns:
Returns the re-allocated bytes or NULL upon failure.
LSVOID LSE_CALL lsc::SetAllocator ( CStdAllocator *  _psaAllocator)

Set the allocator. If different from the current allocator, the dictionary is reset.

Parameters:
_psaAllocatorThe allocator to use by this class.
LSVOID LSE_CALL lsc::SetAllocator ( CAllocator *  _paAllocator)

Set the allocator. Causes all data in the bit stream to be lost if the allocator is not the same as the only already set.

Parameters:
_paAllocatorThe allocator to use by this class.

Variable Documentation

Our dictionary.

The dictionary we use.

CAllocator* lsc::m_paAllocator

Our allocator.

 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator