Ejemplo n.º 1
0
void Entry::Encode(Node * cnode, ArithmeticCoderC * mAc)
{
	std::string str;
	std::vector<std::string> del_symb_copy;
	Interval *interval = new Interval();
	std::vector<Node*> *sorted_children = new std::vector<Node*>;

	str = ReturnSymbolOrESC();	// Returns which string will be encoded: an escape or a symbol

	interval->FindTotal(*del_symb, cnode);
	
	del_symb_copy = *del_symb;

	del_symb->clear();

	*sorted_children = cnode->Node::GetSortedChildren(del_symb_copy, del_symb);

	interval->FindLowHigh(str, sorted_children, cnode);	

	UpdateProb(*interval);

	//std::clog << "symbol: " << str << " - low = " << interval->getLow() << ", high = " << interval->getHigh() << ", total = " << interval->getTotal() << std::endl;
	mAc->Encode(interval->getLow(), interval->getHigh(), interval->getTotal());

	delete interval;
	delete sorted_children;
}
Ejemplo n.º 2
0
int Entry::Encode(int alphabet_size, ArithmeticCoderC * mAc)
{
	int high = alphabet_size;
	int low = --alphabet_size;
	Interval * interval = new Interval(low, high, high);

	UpdateProb(*interval);

	//std::clog << "symbol:" << symbol << " - low = " << low << ", high = " << high << ", total = " << high << std::endl;
	mAc->Encode(interval->getLow(), interval->getHigh(), interval->getTotal());
	
	delete interval;

	return alphabet_size;

}
Ejemplo n.º 3
0
void Entry::UpdateProb(Interval interval)
{
	prob->push_back((double) (interval.getHigh() - interval.getLow()) / interval.getTotal());
}