/// @file zeroorder_modeler.cpp
/// A simple zero-order modeler, which just uses summary frequencies of symbols
///
/// @author mouser
/// @date   2003.07.29
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
#include "zeroorder_modeler.hpp"
//---------------------------------------------------------------------------



	
	
//---------------------------------------------------------------------------
// MODELLER PUBLIC API

bool ZeroOrderModeler::CreateModelUsingStream(OctaneParser *parserp, bitreader &from)
{
	// build a model of frequencies
	bool bretv;

	// calculate symbol frequencies, by asking the weightvector to do our dirty work in conjunction with the parser
	bretv=weightvector.CountSymbolFrequencies(parserp,from);

	// make sure no symbol has freq count == 0 which would break huffman coder and others
	weightvector.EnforceZeroCountFloor(1);

	// normalize to probability distribution
	weightvector.NormalizeToProbabilityDistribution();

	// success
	return bretv;
}
//---------------------------------------------------------------------------
