"L. Spiro Engine"
|
Various types of specialized compression routines. More...
#include <LSCMisc.h>
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) |
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.
typedef CVectorPoD<LSUINT8, LSUINT32, 1048576UL> lsc::CMisc::LSC_BUFFER |
A buffer used to hold compressed data. It is simply a vector of bytes.
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.
_pui8Input | The input data to compress. |
_ui32Length | Length of the input data to compress. |
_ui32Bits | The maximum bit depth. |
_bsStream | The compressed data. |
_ui32MaxSize | The maximum size of the compressed data. If the compression size exceeds this, compression is stopped and false is returned. |
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.
_pui8Input | The input data to compress. |
_ui32Length | Length of the input data to compress. |
_ui32Bits | The returned bit depth. |
_bsStream | The compressed data. |
static LSBOOL LSE_CALL lsc::CMisc::CompressIndices | ( | const LSUINT32 * | _pui32Input, |
LSUINT32 | _ui32Length, | ||
lsc::CBitStream & | _bsStream | ||
) | [static] |
Compress index data to a given bitsream.
_pui32Input | The input data to compress. |
_ui32Length | Number of indices to to which _pui32Input points. |
_bsStream | The compressed data. |
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.
_pui32Input | The input data to compress. |
_ui32Length | Number of indices to to which _pui32Input points. |
_bBuffer | The buffer to which to write the bytes. |
Returns | true 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.
_pvIn | The input 3D vector. |
_ui32Total | The number of vectors to which _pvIn points. |
_vOut | The output 2D vector containing the X and Y components of the input vector. |
_bsSigns | The output sign array. Each bit represents one Z sign. |
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.
_pui8Input | The input data to compress. |
_ui32Length | Length of the input data to compress. |
_bBuffer | The buffer to which to write the bytes. |
Returns | true 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()
_bsStream | The data to decompress. |
_bBuffer | Holds the expanded data. |
static LSBOOL LSE_CALL lsc::CMisc::DecompressIndicesToBuffer | ( | const LSVOID * | _pvData, |
LSUINTPTR | _uiptrSize, | ||
LSC_BUFFER & | _bBuffer | ||
) | [static] |
Decompress indices from packed data to a buffer.
_pvData | Pointer to the data to expand. |
_uiptrSize | Size of the data to expand in bytes. |
_bBuffer | Holds the expanded data in which every index is 32 bits. |
static LSBOOL LSE_CALL lsc::CMisc::DecompressIndicesToBuffer | ( | const lsstd::IStream & | _isStream, |
LSC_BUFFER & | _bBuffer | ||
) | [static] |
Decompress indices from packed data to a buffer.
_isStream | The data to decompress. |
_bBuffer | Holds the expanded data in which every index is 32 bits. |
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.
_pvNormal2d | An array of 2D normals containing the X and Y components of the expanded 3D normal. |
_bsSigns | The array of Z signs. 1 bit per sign. |
_ui32Total | The number of normals to which _pvNormal2d points. |
_pvOut | The 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.
_pvData | Pointer to the data to expand. |
_uiptrSize | Size of the data to expand in bytes. |
_bBuffer | Holds the expanded data. |
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.
_isStream | Stream containing the bytes to expand. |
_bBuffer | Holds the expanded data. |
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.
_i32Value | The value to count how many bits are needed to store assuming the top bit is reserved for signs. |
static LSINT32 LSE_CALL lsc::CMisc::GetSignedValue | ( | const lsc::CBitStream & | _bsStream, |
LSUINT32 | _ui32Bits | ||
) | [static, protected] |
Get a signed number from a stream.
_bsStream | Stream from which to get the signed value. |
_ui32Bits | Number of bits used to store the value. |
static LSBOOL LSE_CALL lsc::CMisc::WriteBytes | ( | const LSUINT8 * | _pui8Bytes, |
LSUINT32 | _ui32Length, | ||
LSC_BUFFER & | _bBuffer | ||
) | [static, protected] |
Write bytes to a buffer.
_pui8Bytes | The values to write to the buffer. |
_ui32Length | Number of bytes to write to the buffer. |
_bBuffer | The buffer to which to write the bytes. |
Returns | true 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.
_ui8Val | The value to write to the buffer. |
_bBuffer | The buffer to which to write the value. |
Returns | true 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.
_ui32Val | The value to write to the file. |
_bBuffer | The buffer to which to write the value. |
Returns | true only if all bytes are written to the given buffer. |