zeroorder_modeler.cpp

来自「Octane v1.01.20 The Open Compression To」· C++ 代码 · 共 37 行

CPP
37
字号
/// @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;
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?