www.pudn.com > ac-win32.zip > ModelOrder0C.cpp
#include "ModelOrder0C.h"
ModelOrder0C::ModelOrder0C()
{
// Häufigkeiten mit 1 initialisieren
mTotal = 257; // 256 + Endsymbol
for( unsigned int i=0; i<257; i++ )
mCumCount[i] = 1;
}
void ModelOrder0C::Encode()
{
while( !mSource->eof() )
{
unsigned char symbol;
// Symbol lesen
mSource->read( reinterpret_cast(&symbol), sizeof( symbol ) );
if( !mSource->eof() )
{
// Häufigkeiten kumulieren
unsigned int low_count = 0;
unsigned char j;
for( j=0; jwrite( reinterpret_cast(&symbol), sizeof( char ) );
// Dekoder anpassen
mAC.Decode( low_count, low_count + mCumCount[ symbol ] );
// update model
mCumCount[ symbol ]++;
mTotal++;
}
while( symbol != 256 );
}