"L. Spiro Engine"
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes

lsc::CZLib Class Reference

A primitive and light-weight implementation of a zlib inflation routine. More...

#include <LSCZLib.h>

List of all members.

Classes

struct  LSC_HUFFMAN

Public Types

typedef CVectorPoD< LSUINT8,
LSUINT32, 0xFFFFUL > 
LSC_ZLIB_BUFFER

Public Member Functions

LSBOOL LSE_CALL DecodeZLib (const LSUINT8 *_pui8Buffer, LSUINTPTR _uiptrLen, LSBOOL _bSkipHeaders, LSC_ZLIB_BUFFER &_zbOut)

Protected Types

enum  { LSC_FAST_BITS = 9UL, LSC_MASK = (1UL << LSC_FAST_BITS) - 1UL }
typedef struct
lsc::CZLib::LSC_HUFFMAN
LPLSC_HUFFMAN
typedef struct
lsc::CZLib::LSC_HUFFMAN 
LPCLSC_HUFFMAN

Protected Member Functions

LSBOOL LSE_CALL FillBits (const CExternalByteStream &_ebsStream)
LSBOOL LSE_CALL Receive (const CExternalByteStream &_ebsStream, LSUINT32 _ui32Total, LSUINT32 &_ui32Return)
LSBOOL LSE_CALL ComputeHuffmanCodes (const CExternalByteStream &_ebsStream)
LSBOOL LSE_CALL BuildHuffman (LSC_HUFFMAN &_hHuffman, const LSUINT8 *_pui8Codes, LSUINT32 _ui32Total)
LSINT32 LSE_CALL DecodeHuffman (const CExternalByteStream &_ebsStream, LSC_HUFFMAN &_hHuffman)
LSBOOL LSE_CALL ParseHuffmanBlock (const CExternalByteStream &_ebsStream, LSC_ZLIB_BUFFER &_zbOut)
LSBOOL LSE_CALL ParseUncompressed (const CExternalByteStream &_ebsStream, LSC_ZLIB_BUFFER &_zbOut)

Static Protected Member Functions

static LSBOOL LSE_CALL CheckHeader (const CExternalByteStream &_ebsStream)
static LSBOOL LSE_CALL ReadUi8 (const CExternalByteStream &_ebsStream, LSUINT8 &_ui8Dst)
static LSE_INLINE LSUINT16 LSE_CALL ReverseBits (LSUINT16 _ui16ReverseMe, LSUINT32 _ui32Shift)
static LSVOID LSE_CALL SetDefaults ()

Protected Attributes

LSUINT32 m_ui32BufferedBits
LSUINT32 m_ui32TotalBitsBuffered
LSC_HUFFMAN m_hLength
LSC_HUFFMAN m_hDistance

Static Protected Attributes

static LSUINT8 m_ui8DefaultLengths [288]
static LSUINT8 m_ui8DefaultDistances [32]
static CCriticalSection m_scCrit

Detailed Description

A primitive and light-weight implementation of a zlib inflation routine.

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


Member Typedef Documentation

typedef struct lsc::CZLib::LSC_HUFFMAN * lsc::CZLib::LPLSC_HUFFMAN [protected]

Huffman table.

typedef CVectorPoD<LSUINT8, LSUINT32, 0xFFFFUL> lsc::CZLib::LSC_ZLIB_BUFFER

The output buffer.


Member Enumeration Documentation

anonymous enum [protected]

Huffman metrics.


Member Function Documentation

LSBOOL LSE_CALL lsc::CZLib::BuildHuffman ( LSC_HUFFMAN _hHuffman,
const LSUINT8 *  _pui8Codes,
LSUINT32  _ui32Total 
) [protected]

Build Huffman codes.

Parameters:
_hHuffmanThe target Huffman buffer.
_pui8CodesLitst of codes.
_ui32TotalLength of the list of codes.
Returns:
Returns false if the stream is not formatted properly.
static LSBOOL LSE_CALL lsc::CZLib::CheckHeader ( const CExternalByteStream &  _ebsStream) [static, protected]

Check the ZLib header.

Parameters:
_ebsStreamThe stream containing the ZLib-compressed buffer.
Returns:
Returns true if the header is valid.
LSBOOL LSE_CALL lsc::CZLib::ComputeHuffmanCodes ( const CExternalByteStream &  _ebsStream) [protected]

Compute the Huffman codes.

Parameters:
_ebsStreamThe stream.
Returns:
Returns false if the stream is not formatted properly.
LSINT32 LSE_CALL lsc::CZLib::DecodeHuffman ( const CExternalByteStream &  _ebsStream,
LSC_HUFFMAN _hHuffman 
) [protected]

Decode a Huffman buffer.

Parameters:
_ebsStreamThe stream.
_hHuffmanThe Huffman buffer.
Returns:
Returns the next code or -1 on error.
LSBOOL LSE_CALL lsc::CZLib::DecodeZLib ( const LSUINT8 *  _pui8Buffer,
LSUINTPTR  _uiptrLen,
LSBOOL  _bSkipHeaders,
LSC_ZLIB_BUFFER _zbOut 
)

Decodes a ZLib buffer, optionally skipping the header as per certain iPhone PNG formats.

Parameters:
_pui8BufferThe compressed buffer to decompress.
_uiptrLenLength of the buffer to decompress.
_bSkipHeadersIf true, headers are skipped.
_zbOutHolds the returned decompressed data.
Returns:
Returns true if the input buffer is valid and if there are no memory problems.
LSBOOL LSE_CALL lsc::CZLib::FillBits ( const CExternalByteStream &  _ebsStream) [protected]

Fill our bit buffer.

Parameters:
_ebsStreamThe stream from which to take bits.
Returns:
Returns false if the stream runs out of bits.
LSBOOL LSE_CALL lsc::CZLib::ParseHuffmanBlock ( const CExternalByteStream &  _ebsStream,
LSC_ZLIB_BUFFER _zbOut 
) [protected]

Parse a Huffman block.

Parameters:
_ebsStreamThe stream.
_zbOutThe output.
Returns:
Returns true if the Huffman block is valid.
LSBOOL LSE_CALL lsc::CZLib::ParseUncompressed ( const CExternalByteStream &  _ebsStream,
LSC_ZLIB_BUFFER _zbOut 
) [protected]

Parse and uncompressed block.

Parameters:
_ebsStreamThe stream.
_zbOutThe output.
Returns:
Returns true if the Huffman block is valid.
static LSBOOL LSE_CALL lsc::CZLib::ReadUi8 ( const CExternalByteStream &  _ebsStream,
LSUINT8 &  _ui8Dst 
) [static, protected]

Reads a single 8-bit value from the given stream.

Parameters:
_ebsStreamThe stream from which to read an 8-bit value.
_ui8DstDestination for the read value.
Returns:
Returns true if the value was read from the stream.
LSBOOL LSE_CALL lsc::CZLib::Receive ( const CExternalByteStream &  _ebsStream,
LSUINT32  _ui32Total,
LSUINT32 &  _ui32Return 
) [protected]

Read X number of bits.

Parameters:
_ebsStreamThe stream from which to take bits.
_ui32TotalThe number of bits to read.
_ui32ReturnHolds the returned value.
Returns:
Returns true if all bits were read.
LSE_INLINE LSUINT16 LSE_CALL lsc::CZLib::ReverseBits ( LSUINT16  _ui16ReverseMe,
LSUINT32  _ui32Shift 
) [static, protected]

Reverse bits and shift off some. The reverse is assumed to be on a 16-bit value.

Parameters:
_ui16ReverseMeThe value to reverse.
_ui32ShiftThe number of bits to keep from the reversed value.
Returns:
Returns the 16-bit reverse and shift of the given value.
static LSVOID LSE_CALL lsc::CZLib::SetDefaults ( ) [static, protected]

Apply default sizes and distances.


Member Data Documentation

Distance Huffman buffer.

Length Huffman buffer.

CCriticalSection lsc::CZLib::m_scCrit [static, protected]

Critcal section for updating the deafult values;

LSUINT32 lsc::CZLib::m_ui32BufferedBits [protected]

Buffered bits.

Total bits buffered.

LSUINT8 lsc::CZLib::m_ui8DefaultDistances[32] [static, protected]

Default distances.

LSUINT8 lsc::CZLib::m_ui8DefaultLengths[288] [static, protected]

Default lengths.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator