Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Burger::CompressILBMRLE Class Reference

Compress data using ILBM Run Length Encoding. More...

Inheritance diagram for Burger::CompressILBMRLE:
Inheritance graph
[legend]
Collaboration diagram for Burger::CompressILBMRLE:
Collaboration graph
[legend]

Public Member Functions

const Burger::StaticRTTIget_StaticRTTI (void) const noexcept override
 Get the description to the class.
 
 CompressILBMRLE (void)
 Default constructor.
 
eError Init (void) override
 Reset the RLE compressor.
 
eError Process (const void *pInput, uintptr_t uInputLength) override
 Compress the input data using RLE.
 
eError Finalize (void) override
 Finalize RLE compression.
 
- Public Member Functions inherited from Burger::Compress
 Compress (void)
 Default constructor.
 
virtual ~Compress ()
 Default destructor.
 
OutputMemoryStreamGetOutput (void) noexcept
 Get the output data.
 
uintptr_t GetOutputSize (void) const noexcept
 Get the output data size in bytes.
 
uint32_t GetSignature (void) const noexcept
 Return the signature for this compressor.
 
- Public Member Functions inherited from Burger::Base
const char * get_class_name (void) const noexcept
 Get the name of the class.
 
virtual ~Base () noexcept=default
 Destructor.
 

Static Public Attributes

static const Burger::StaticRTTI g_StaticRTTI
 The global description of the class.
 
static const uint32_t Signature = 0x524C4420
 'RLE '
 
- Static Public Attributes inherited from Burger::Compress
static const Burger::StaticRTTI g_StaticRTTI
 The global description of the class.
 
- Static Public Attributes inherited from Burger::Base
static const Burger::StaticRTTI g_StaticRTTI
 The global description of the class.
 

Protected Member Functions

eError Compact (const uint8_t *pInput, uintptr_t uInputLength)
 Compress the input data using RLE.
 

Protected Attributes

uintptr_t m_uCacheUsed
 Number of bytes in the cache.
 
uintptr_t m_uRemaining
 Number of bytes unprocessed from the last call to Compact()
 
uint8_t m_Cache [128+8]
 Data cache for resuming compression.
 
- Protected Attributes inherited from Burger::Compress
OutputMemoryStream m_Output
 Main output buffer for compressed data.
 
uint32_t m_uSignature
 4 character code to identify this compressor
 

Detailed Description

Compress data using ILBM Run Length Encoding.


This simple format encodes a data stream by finding runs of duplicated data and encodes the duplicates into a count/byte pair. Otherwise, it's a count followed by a stream of raw data.

The format is as follows, a byte is taken which is either above 128 or less than 128. If higher than 128, it's a repeater, if less than 128, it's a count.

128 is considered a "No Operation" or end of line for the data stream. As such, 128 is not allowed to be encoded.

uint8_t uToken = pDataStream[0];
if (uToken>128) {
uint_t uCount = 257-uToken;
MemoryFill(pOutput,pDataStream[1],uCount);
pDataStream+=2;
} else if (uToken<128) {
uint_t uCount = uToken+1;
MemoryCopy(pOutput,pDataStream+1,uCount);
pDataStream+=uCount+1;
} else if (uToken==128) {
// Do nothing, as per ILBM specifications
}
unsigned int uint_t
Unsigned integer.
Definition burger.h:1513
void MemoryFill(void *pOutput, uint8_t uFill, uintptr_t uCount) noexcept
Set a buffer to a specific value.
Definition brmemoryfunctions.cpp:360
void MemoryCopy(void *pOutput, const void *pInput, uintptr_t uCount) noexcept
Copy raw memory from one buffer to another.
Definition brmemoryfunctions.cpp:186
See also
Burger::DecompressILBMRLE

Constructor & Destructor Documentation

◆ CompressILBMRLE()

Burger::CompressILBMRLE::CompressILBMRLE ( void )

Default constructor.


Initializes the cache buffer.

Member Function Documentation

◆ Compact()

Burger::eError Burger::CompressILBMRLE::Compact ( const uint8_t * pInput,
uintptr_t uInputLength )
protected

Compress the input data using RLE.


Compresses the data using RLE and stores the compressed data into an OutputMemoryStream. If there is any excess data, record the size in CompressILBMRLE::m_uRemaining

◆ Finalize()

Burger::eError Burger::CompressILBMRLE::Finalize ( void )
overridevirtual

Finalize RLE compression.


If any data has been cached from the compression stream, flush it into the output

Returns
Zero if no error, non-zero on error

Implements Burger::Compress.

◆ get_StaticRTTI()

const Burger::StaticRTTI * Burger::CompressILBMRLE::get_StaticRTTI ( void ) const
overridevirtualnoexcept

Get the description to the class.


This virtual function will pull the pointer to the StaticRTTI instance that has the name of the class. Due to it being virtual, it will be the name of the most derived class.

Returns
Pointer to a global, read only instance of StaticRTTI for the true class

Reimplemented from Burger::Compress.

◆ Init()

Burger::eError Burger::CompressILBMRLE::Init ( void )
overridevirtual

Reset the RLE compressor.


Resets the cache buffer.

Implements Burger::Compress.

◆ Process()

Burger::eError Burger::CompressILBMRLE::Process ( const void * pInput,
uintptr_t uInputLength )
overridevirtual

Compress the input data using RLE.


Compresses the data using RLE and stores the compressed data into an OutputMemoryStream

Implements Burger::Compress.

Member Data Documentation

◆ g_StaticRTTI

const Burger::StaticRTTI Burger::CompressILBMRLE::g_StaticRTTI
static

The global description of the class.


This record contains the name of this class and a reference to the parent

◆ m_Cache

uint8_t Burger::CompressILBMRLE::m_Cache[128+8]
protected

Data cache for resuming compression.

◆ m_uCacheUsed

uintptr_t Burger::CompressILBMRLE::m_uCacheUsed
protected

Number of bytes in the cache.

◆ m_uRemaining

uintptr_t Burger::CompressILBMRLE::m_uRemaining
protected

Number of bytes unprocessed from the last call to Compact()

◆ Signature

const uint32_t Burger::CompressILBMRLE::Signature = 0x524C4420
static

'RLE '