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

lsc::CMisc Class Reference

Various types of specialized compression routines. More...

#include <LSCMisc.h>

List of all members.

Public Types

typedef CVectorPoD< LSUINT8,
LSUINT32, 1048576UL > 
LSC_BUFFER

Static Public Member Functions

static LSBOOL LSE_CALL CompressNormals (const CVector3 *_pvIn, LSUINT32 _ui32Total, CVectorPoD< CVector2, LSUINT32 > &_vOut, lsc::CBitStream &_bsSigns)
static LSVOID LSE_CALL DecompressNormals (const CVector2 *_pvNormal2d, const lsc::CBitStream &_bsSigns, LSUINT32 _ui32Total, CVector3 *_pvOut)
static LSBOOL LSE_CALL Compress (const LSUINT8 *_pui8Input, LSUINT32 _ui32Length, LSUINT32 _ui32Bits, lsc::CBitStream &_bsStream, LSUINT32 _ui32MaxSize=~0UL)
static LSBOOL LSE_CALL CompressBest (const LSUINT8 *_pui8Input, LSUINT32 _ui32Length, LSUINT32 &_ui32Bits, lsc::CBitStream &_bsStream)
static LSBOOL LSE_CALL CompressToBuffer (const LSUINT8 *_pui8Input, LSUINT32 _ui32Length, LSC_BUFFER &_bBuffer)
static LSBOOL LSE_CALL DecompressToBuffer (const LSVOID *_pvData, LSUINTPTR _uiptrSize, LSC_BUFFER &_bBuffer)
static LSBOOL LSE_CALL DecompressToBuffer (const lsstd::IStream &_isStream, LSC_BUFFER &_bBuffer)
static LSBOOL LSE_CALL CompressIndices (const LSUINT32 *_pui32Input, LSUINT32 _ui32Length, lsc::CBitStream &_bsStream)
static LSBOOL LSE_CALL DecompressIndices (const lsc::CBitStream &_bsStream, LSC_BUFFER &_bBuffer)
static LSBOOL LSE_CALL CompressIndicesToBuffer (const LSUINT32 *_pui32Input, LSUINT32 _ui32Length, LSC_BUFFER &_bBuffer)
static LSBOOL LSE_CALL DecompressIndicesToBuffer (const LSVOID *_pvData, LSUINTPTR _uiptrSize, LSC_BUFFER &_bBuffer)
static LSBOOL LSE_CALL DecompressIndicesToBuffer (const lsstd::IStream &_isStream, LSC_BUFFER &_bBuffer)

Static Protected Member Functions

static LSBOOL LSE_CALL WriteBytes (const LSUINT8 *_pui8Bytes, LSUINT32 _ui32Length, LSC_BUFFER &_bBuffer)
static LSBOOL LSE_CALL WriteUChar (LSUINT8 _ui8Val, LSC_BUFFER &_bBuffer)
static LSBOOL LSE_CALL WriteUInt (LSUINT32 _ui32Val, LSC_BUFFER &_bBuffer)
static LSUINT32 LSE_CALL GetBitsNeededForSignedValue (LSINT32 _i32Value)
static LSINT32 LSE_CALL GetSignedValue (const lsc::CBitStream &_bsStream, LSUINT32 _ui32Bits)

Detailed Description

Various types of specialized compression routines.

Class CMisc 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.


Member Typedef Documentation

typedef CVectorPoD<LSUINT8, LSUINT32, 1048576UL> lsc::CMisc::LSC_BUFFER

A buffer used to hold compressed data. It is simply a vector of bytes.


Member Function Documentation

static LSBOOL LSE_CALL lsc::CMisc::Compress ( const LSUINT8 *  _pui8Input,
LSUINT32  _ui32Length,
LSUINT32  _ui32Bits,
lsc::CBitStream &  _bsStream,
LSUINT32  _ui32MaxSize = ~0UL 
) [static]

Compress data at a given bit depth.

Parameters:
_pui8InputThe input data to compress.
_ui32LengthLength of the input data to compress.
_ui32BitsThe maximum bit depth.
_bsStreamThe compressed data.
_ui32MaxSizeThe maximum size of the compressed data. If the compression size exceeds this, compression is stopped and false is returned.
Returns:
Returns true if there was enough memory to perform the encoding.
static LSBOOL LSE_CALL lsc::CMisc::CompressBest ( const LSUINT8 *  _pui8Input,
LSUINT32  _ui32Length,
LSUINT32 &  _ui32Bits,
lsc::CBitStream &  _bsStream 
) [static]

Find the best compression size and return the compressed bytes and the bit-count.

Parameters:
_pui8InputThe input data to compress.
_ui32LengthLength of the input data to compress.
_ui32BitsThe returned bit depth.
_bsStreamThe compressed data.
Returns:
Returns true if a suitable compression was found, false otherwise.
static LSBOOL LSE_CALL lsc::CMisc::CompressIndices ( const LSUINT32 *  _pui32Input,
LSUINT32  _ui32Length,
lsc::CBitStream &  _bsStream 
) [static]

Compress index data to a given bitsream.

Parameters:
_pui32InputThe input data to compress.
_ui32LengthNumber of indices to to which _pui32Input points.
_bsStreamThe compressed data.
Returns:
Returns true if there was enough memory to perform the encoding.
static LSBOOL LSE_CALL lsc::CMisc::CompressIndicesToBuffer ( const LSUINT32 *  _pui32Input,
LSUINT32  _ui32Length,
LSC_BUFFER _bBuffer 
) [static]

Compress index data to a buffer. If the compression is larger than the original data, the original data is written instead.

Parameters:
_pui32InputThe input data to compress.
_ui32LengthNumber of indices to to which _pui32Input points.
_bBufferThe buffer to which to write the bytes.
Returnstrue only if all bytes are written to the given buffer.
static LSBOOL LSE_CALL lsc::CMisc::CompressNormals ( const CVector3 *  _pvIn,
LSUINT32  _ui32Total,
CVectorPoD< CVector2, LSUINT32 > &  _vOut,
lsc::CBitStream &  _bsSigns 
) [static]

Compress an array of normals. The normals are assumed to be of unit length. Works by removing the entire Z component except for its sign, which is returned separately. Normals are reconstructed by determining the Z value that makes the normal unit-length again.

Parameters:
_pvInThe input 3D vector.
_ui32TotalThe number of vectors to which _pvIn points.
_vOutThe output 2D vector containing the X and Y components of the input vector.
_bsSignsThe output sign array. Each bit represents one Z sign.
Returns:
Returns true if there are no memory problems during the compression.
static LSBOOL LSE_CALL lsc::CMisc::CompressToBuffer ( const LSUINT8 *  _pui8Input,
LSUINT32  _ui32Length,
LSC_BUFFER _bBuffer 
) [static]

Compress bytes to a buffer. If the compression is larger than the original data, the original data is written instead.

Parameters:
_pui8InputThe input data to compress.
_ui32LengthLength of the input data to compress.
_bBufferThe buffer to which to write the bytes.
Returnstrue only if all bytes are written to the given buffer.
static LSBOOL LSE_CALL lsc::CMisc::DecompressIndices ( const lsc::CBitStream &  _bsStream,
LSC_BUFFER _bBuffer 
) [static]

Decompress indices that are not further compressed to a buffer. Input data must have been created with a call to CompressIndices()

Parameters:
_bsStreamThe data to decompress.
_bBufferHolds the expanded data.
Returns:
Returns true if the input is valid and if there is enough memory to perform the expansion. False is returned otherwise.
static LSBOOL LSE_CALL lsc::CMisc::DecompressIndicesToBuffer ( const LSVOID *  _pvData,
LSUINTPTR  _uiptrSize,
LSC_BUFFER _bBuffer 
) [static]

Decompress indices from packed data to a buffer.

Parameters:
_pvDataPointer to the data to expand.
_uiptrSizeSize of the data to expand in bytes.
_bBufferHolds the expanded data in which every index is 32 bits.
Returns:
Returns true if the input is valid and if there is enough memory to perform the expansion. False is returned otherwise.
static LSBOOL LSE_CALL lsc::CMisc::DecompressIndicesToBuffer ( const lsstd::IStream _isStream,
LSC_BUFFER _bBuffer 
) [static]

Decompress indices from packed data to a buffer.

Parameters:
_isStreamThe data to decompress.
_bBufferHolds the expanded data in which every index is 32 bits.
Returns:
Returns true if the input is valid and if there is enough memory to perform the expansion. False is returned otherwise.
static LSVOID LSE_CALL lsc::CMisc::DecompressNormals ( const CVector2 *  _pvNormal2d,
const lsc::CBitStream &  _bsSigns,
LSUINT32  _ui32Total,
CVector3 *  _pvOut 
) [static]

Decompress normals to a buffer that is of the correct length to hold all of the decompressed normals.

Parameters:
_pvNormal2dAn array of 2D normals containing the X and Y components of the expanded 3D normal.
_bsSignsThe array of Z signs. 1 bit per sign.
_ui32TotalThe number of normals to which _pvNormal2d points.
_pvOutThe output buffer. Must be allocated to hold _ui32Total 3D normals.
static LSBOOL LSE_CALL lsc::CMisc::DecompressToBuffer ( const LSVOID *  _pvData,
LSUINTPTR  _uiptrSize,
LSC_BUFFER _bBuffer 
) [static]

Decompress from packed data of any kind to a buffer. If the expanded size is known beforehand, call Allocate() on the buffer to improve the performance of this call.

Parameters:
_pvDataPointer to the data to expand.
_uiptrSizeSize of the data to expand in bytes.
_bBufferHolds the expanded data.
Returns:
Returns true if the input is valid and if there is enough memory to perform the expansion. False is returned otherwise.
static LSBOOL LSE_CALL lsc::CMisc::DecompressToBuffer ( const lsstd::IStream _isStream,
LSC_BUFFER _bBuffer 
) [static]

Decompress from packed data of any kind to a buffer. If the expanded size is known beforehand, call Allocate() on the buffer to improve the performance of this call.

Parameters:
_isStreamStream containing the bytes to expand.
_bBufferHolds the expanded data.
Returns:
Returns true if the input is valid and if there is enough memory to perform the expansion. False is returned otherwise.
static LSUINT32 LSE_CALL lsc::CMisc::GetBitsNeededForSignedValue ( LSINT32  _i32Value) [static, protected]

Get the number of bits needed to store a number assumed to be signed.

Parameters:
_i32ValueThe value to count how many bits are needed to store assuming the top bit is reserved for signs.
Returns:
Returns the number of bits needed to store a number assumed to be signed.
static LSINT32 LSE_CALL lsc::CMisc::GetSignedValue ( const lsc::CBitStream &  _bsStream,
LSUINT32  _ui32Bits 
) [static, protected]

Get a signed number from a stream.

Parameters:
_bsStreamStream from which to get the signed value.
_ui32BitsNumber of bits used to store the value.
Returns:
Returns the signed value.
static LSBOOL LSE_CALL lsc::CMisc::WriteBytes ( const LSUINT8 *  _pui8Bytes,
LSUINT32  _ui32Length,
LSC_BUFFER _bBuffer 
) [static, protected]

Write bytes to a buffer.

Parameters:
_pui8BytesThe values to write to the buffer.
_ui32LengthNumber of bytes to write to the buffer.
_bBufferThe buffer to which to write the bytes.
Returnstrue only if all bytes are written to the given buffer.
static LSBOOL LSE_CALL lsc::CMisc::WriteUChar ( LSUINT8  _ui8Val,
LSC_BUFFER _bBuffer 
) [static, protected]

Write a byte to a buffer.

Parameters:
_ui8ValThe value to write to the buffer.
_bBufferThe buffer to which to write the value.
Returnstrue only if all bytes are written to the given buffer.
static LSBOOL LSE_CALL lsc::CMisc::WriteUInt ( LSUINT32  _ui32Val,
LSC_BUFFER _bBuffer 
) [static, protected]

Write an unsigned integer to a buffer.

Parameters:
_ui32ValThe value to write to the file.
_bBufferThe buffer to which to write the value.
Returnstrue only if all bytes are written to the given buffer.

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