当前位置: 首页>>代码示例>>C++>>正文


C++ OutBuffer::writebits方法代码示例

本文整理汇总了C++中OutBuffer::writebits方法的典型用法代码示例。如果您正苦于以下问题:C++ OutBuffer::writebits方法的具体用法?C++ OutBuffer::writebits怎么用?C++ OutBuffer::writebits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OutBuffer的用法示例。


在下文中一共展示了OutBuffer::writebits方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: deflate_dynamic

void deflate_dynamic(OutBuffer &buf, vector<Symb> &lz77Coded, vector<int> &litLens, vector<int> &dstLens) {
	short BTYPE = 2;
	buf.writebits(BTYPE, 2, true);

	int HLIT = Hcount(litLens, 257);
	int HDIST = Hcount(dstLens, 1);

	vector<Symb> HCcoded = HC_encode(HLIT, HDIST, litLens, dstLens);

	vector<int> hcProbs(19, 0);
	for (int i = 0; i < HCcoded.size(); i++)
		hcProbs[HCcoded[i].lit]++;

	vector<int> hcLens(19);
	Huffman_builder(hcProbs, hcLens);
	vector<int> hcCodes = get_codes(hcLens, 8);

	int HCLEN = 4;
	for (int i = 4; i < hcLens.size(); i++)
		if (hcLens[hcOrder[i]]) HCLEN = i + 1;

	buf.writebits(HLIT - 257, 5, true);
	buf.writebits(HDIST - 1, 5, true);
	buf.writebits(HCLEN - 4, 4, true);

	print_hc_encoded(buf, HCLEN, hcCodes, hcLens, HCcoded);

	int maxLen = 20;
	vector<int> litCodes = get_codes(litLens, maxLen);
	vector<int> dstCodes = get_codes(dstLens, maxLen);
	print_encoded(buf, lz77Coded, litCodes, litLens, dstCodes, dstLens);
}
开发者ID:glebmish,项目名称:Deflate_archiver,代码行数:32,代码来源:Deflate.cpp

示例2: print_encoded

void print_encoded(OutBuffer &buf, vector<Symb> coded, vector<int> litCodes, vector<int> litLens, vector<int> dstCodes, vector<int> dstLens) {
	for (int i = 0; i < coded.size(); i++) {
		Symb cur = coded[i];
		vector<int> &code = (cur.isLit) ? litCodes : dstCodes;
		vector<int> &len = (cur.isLit) ? litLens : dstLens;

		buf.writebits(code[cur.lit], len[cur.lit], false);
		buf.writebits(cur.add, cur.addLen, true);
	}
}
开发者ID:glebmish,项目名称:Deflate_archiver,代码行数:10,代码来源:Deflate.cpp

示例3: print_hc_encoded

void print_hc_encoded(OutBuffer &buf, int HCLEN, vector<int> hcCodes, vector<int> hcLens, vector<Symb> coded) {
	for (int i = 0; i < HCLEN; i++)
		buf.writebits(hcLens[hcOrder[i]], 3, true);

	for (int i = 0; i < coded.size(); i++) {
		Symb cur = coded[i];

		buf.writebits(hcCodes[cur.lit], hcLens[cur.lit], false);
		buf.writebits(cur.add, cur.addLen, true);
	}
}
开发者ID:glebmish,项目名称:Deflate_archiver,代码行数:11,代码来源:Deflate.cpp

示例4: deflate_stored

void deflate_stored(OutBuffer &buf, vector<unsigned char> &charList) {
	short BTYPE = 0;
	buf.writebits(BTYPE, 2, true);
	buf.writebits(0, 5, true); //stored bytes should start from byte bound

	short LEN = charList.size();
	buf.writebits(LEN, 16, true);
	buf.writebits(~LEN, 16, true);

	for (int i = 0; i < LEN; ++i)
		buf.writebits(charList[i], 8, true);
}
开发者ID:glebmish,项目名称:Deflate_archiver,代码行数:12,代码来源:Deflate.cpp

示例5: deflate_fixed

void deflate_fixed(OutBuffer &buf, vector<Symb> &lz77Coded, vector<int> litLens, vector<int> dstLens) {
	short BTYPE = 1;
	buf.writebits(BTYPE, 2, true);

	int maxLen = 20;
	vector<int> litCodes = get_codes(litLens, maxLen);
	vector<int> dstCodes = get_codes(dstLens, maxLen);
	print_encoded(buf, lz77Coded, litCodes, litLens, dstCodes, dstLens);
}
开发者ID:glebmish,项目名称:Deflate_archiver,代码行数:9,代码来源:Deflate.cpp


注:本文中的OutBuffer::writebits方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。