Octane v1.01.20 - The Open Compression Toolkit for C++ | http://octane.sourceforge.net/ |
00001 00002 00003 00004 00005 00006 //--------------------------------------------------------------------------- 00007 00008 //--------------------------------------------------------------------------- 00009 #include "zeroorder_modeler.hpp" 00010 //--------------------------------------------------------------------------- 00011 00012 00013 00014 00015 00016 //--------------------------------------------------------------------------- 00017 // MODELLER PUBLIC API 00018 00019 bool ZeroOrderModeler::CreateModelUsingStream(OctaneParser *parserp, bitreader &from) 00020 { 00021 // build a model of frequencies 00022 bool bretv; 00023 00024 // calculate symbol frequencies, by asking the weightvector to do our dirty work in conjunction with the parser 00025 bretv=weightvector.CountSymbolFrequencies(parserp,from); 00026 00027 // make sure no symbol has freq count == 0 which would break huffman coder and others 00028 weightvector.EnforceZeroCountFloor(1); 00029 00030 // normalize to probability distribution 00031 weightvector.NormalizeToProbabilityDistribution(); 00032 00033 // success 00034 return bretv; 00035 } 00036 //---------------------------------------------------------------------------