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


C++ BitStream::FlushInputWordBuffer方法代码示例

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


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

示例1: ReadLzMatches

// ********************************************************************************************
void Block::ReadLzMatches(BitStream &bit_stream, LzMatcher &lz_matcher)
{
	for (uint32 i = 0; i < rec_count; ++i)
	{
		uint32 tmp(0);			// remove warning...
		bit_stream.GetBit(tmp);
		lz_matches[i].length = tmp;
		if (!lz_matches[i].length)
		{
			bit_stream.GetBit(tmp);
			records[i].lz_inserted = tmp != 0;
		}
	}
	bit_stream.FlushInputWordBuffer();

	// DNA data
	uint32 rec_no_bits = BitStream::BitLength(b_start_rec_no + rec_count - 1);
	uint32 length_bits;
	uint32 offset_bits = (uint32)MAX(0, (int32)global_max_sequence_length - (int32)lz_matcher.GetMinMatchLen());

	if (offset_bits)
	{
		offset_bits = BitStream::BitLength(offset_bits);
	}

	for (uint32 i = 0; i < rec_count; ++i)
	{
		if (lz_matches[i].length > 0)
		{
			uint32 tmp;
			bit_stream.GetBits(tmp, rec_no_bits);
			lz_matches[i].rec_no = tmp;

			length_bits = (uint32)MAX(0, MIN((int32)records[i].sequence_len - (int32)lz_matcher.GetMinMatchLen(), 255));
			if (length_bits)
			{
				length_bits = BitStream::BitLength(length_bits);
				bit_stream.GetBits(tmp, length_bits);
			}
			else
			{
				tmp = 0;
			}
			lz_matches[i].length = tmp + lz_matcher.GetMinMatchLen();

			if (offset_bits)
			{
				bit_stream.GetBits(tmp, offset_bits);
			}
			else
			{
				tmp = 0;
			}
			lz_matches[i].rec_offset = tmp;
		}
	}
	bit_stream.FlushInputWordBuffer();
}
开发者ID:PCDS,项目名称:paraDSRC,代码行数:59,代码来源:block.cpp

示例2: ReadDNAPlain

// ********************************************************************************************
void Block::ReadDNAPlain(BitStream &bit_stream, LzMatcher &lz_matcher, std::vector<uchar> &symbols, bool try_lz, bool extracting)
{
	// Info about LZ matches
	lz_matches.resize(rec_count);
	
	for (uint32 i = 0; i < rec_count; ++i)
	{
		records[i].sequence_len = records[i].quality_len - no_of_amb[i];
	}

	if (try_lz)
	{
		ReadLzMatches(bit_stream, lz_matcher);

		for (uint32 i = 0; i < rec_count; ++i)
		{
			if (!extracting)
				DecodeLzMatches(lz_matcher, i);

			uint32 cur_sequence_len = records[i].sequence_len;
			uchar *cur_sequence = records[i].sequence;
			my_assert(lz_matches[i].length <= cur_sequence_len);
			for (uint32 j = lz_matches[i].length; j < cur_sequence_len; ++j)
			{
				uint32 tmp(0);	// remove warning...
				bit_stream.Get2Bits(tmp);
				cur_sequence[j] = symbols[tmp];
			}	
			cur_sequence[cur_sequence_len] = '\0';

			if (!extracting)
				DecodeLzMatches_Insert(lz_matcher, i);
		}
	}
	else
	{
		for (uint32 i = 0; i < rec_count; ++i)
		{
			lz_matches[i].length = 0;
			uint32 cur_sequence_len = records[i].sequence_len;
			uchar *cur_sequence = records[i].sequence;

			for (uint32 j = 0; j < cur_sequence_len; ++j)
			{
				uint32 tmp(0);			// reduce warning...
				bit_stream.Get2Bits(tmp);
				cur_sequence[j] = symbols[tmp];
			}	
			cur_sequence[cur_sequence_len] = '\0';
		}
	}

	bit_stream.FlushInputWordBuffer();
}
开发者ID:PCDS,项目名称:paraDSRC,代码行数:55,代码来源:block.cpp

示例3: ReadQualityRLE

// ********************************************************************************************
void Block::ReadQualityRLE(BitStream &bit_stream, std::vector<uchar> &qualities, 
std::vector<HuffmanEncoder*> &Huffman_qua, int32 /*n_qualities*/, std::vector<HuffmanEncoder*> &Huffman_run, 
int32 /*max_run_len*/)
{
	int32 max_len = 0;
	uint32 i = 0;
	for (; i < rec_count; ++i)
	{
		max_len += records[i].quality_len;
	}

	qua_stream_len = run_stream_len = max_len;
	qua_stream = new uchar[max_len];
	run_stream = new uchar[max_len];


	uint32 prev = 0;
	i = 0;
	for (uint32 j = 0; j < qua_stream_len; ++i)
	{
		int32 h_tmp;
		uint32 bit;

		// Quality data
		bit_stream.GetBits(bit, Huffman_qua[prev]->GetMinLen());
		h_tmp = Huffman_qua[prev]->DecodeFast(bit);

		while (h_tmp < 0)
		{
			bit_stream.GetBit(bit);
			h_tmp = Huffman_qua[prev]->Decode(bit);
		};

		my_assert(h_tmp < (int32)qualities.size());
		qua_stream[i] = qualities[h_tmp];
		prev = h_tmp;

		// Run data
		bit_stream.GetBits(bit, Huffman_run[prev]->GetMinLen());
		h_tmp = Huffman_run[prev]->DecodeFast(bit);

		while (h_tmp < 0)
		{
			bit_stream.GetBit(bit);
			h_tmp = Huffman_run[prev]->Decode(bit);
		};

		run_stream[i] = (uchar) h_tmp;

		j += h_tmp+1;
	}

	bit_stream.FlushInputWordBuffer();
}
开发者ID:PCDS,项目名称:paraDSRC,代码行数:55,代码来源:block.cpp

示例4: LoadTree

// ********************************************************************************************
void HuffmanEncoder::LoadTree(BitStream& bit_stream, HuffmanEncoder& tree)
{
	static uchar* mem_buf = NULL;
	static uint32 mem_size;

	bit_stream.FlushInputWordBuffer();

	bit_stream.GetWord(mem_size);
	my_assert(mem_size > 0);
	mem_buf = new uchar[mem_size];
	bit_stream.GetBytes(mem_buf, mem_size);
	tree.LoadTree(mem_buf, mem_size);

	delete [] mem_buf;
}
开发者ID:PCDS,项目名称:paraDSRC,代码行数:16,代码来源:huffman.cpp

示例5: ReadQualityPlain

// ********************************************************************************************
void Block::ReadQualityPlain(BitStream &bit_stream, std::vector<uchar> &qualities, 
	std::vector<HuffmanEncoder*> &Huffman_qua, int32 /*n_qualities*/, bool trucated_hashes, bool /*uses_const_delta*/)
{
	// Quality data
	for (uint32 i = 0; i < rec_count; ++i)
	{
		no_of_amb[i] = 0;
		uchar *cur_quality = records[i].quality; 
		uint32 cur_quality_len = records[i].quality_len;
		uint32 trunc_len = 0;

		if (trucated_hashes)			// Truncate #
		{
			uint32 is_truncated(0);		// skip warning...
			bit_stream.GetBit(is_truncated);
			if (is_truncated)
			{
				bit_stream.GetBits(trunc_len, BitStream::BitLength(cur_quality_len));
			}
		}

		for (uint32 j = 0; j < cur_quality_len-trunc_len; ++j)
		{
			uint32 bit;
			int32 h_tmp;

			bit_stream.GetBits(bit, Huffman_qua[j+1]->GetMinLen());
			h_tmp = Huffman_qua[j+1]->DecodeFast(bit);

			while (h_tmp < 0)
			{
				bit_stream.GetBit(bit);
				h_tmp = Huffman_qua[j+1]->Decode(bit);
			};

			if ((cur_quality[j] = qualities[h_tmp]) >= 128)
			{
				no_of_amb[i]++;
			}
		}

		for (uint32 j = cur_quality_len-trunc_len; j < cur_quality_len; ++j)
		{
			cur_quality[j] = '#';
		}
	}
	bit_stream.FlushInputWordBuffer();
}
开发者ID:PCDS,项目名称:paraDSRC,代码行数:49,代码来源:block.cpp

示例6: ReadDNAHuf

// ********************************************************************************************
void Block::ReadDNAHuf(BitStream &bit_stream, LzMatcher &lz_matcher, std::vector<uchar> &symbols, HuffmanEncoder *Huffman_sym, bool try_lz, bool extracting)
{
	// Info about LZ matches
	lz_matches.resize(rec_count);
	
	for (uint32 i = 0; i < rec_count; ++i)
	{
		records[i].sequence_len = records[i].quality_len - no_of_amb[i];
	}

	if (try_lz)
	{
		ReadLzMatches(bit_stream, lz_matcher);

		for (uint32 i = 0; i < rec_count; ++i)
		{
			if (!extracting)
				DecodeLzMatches(lz_matcher, i);

			uint32 cur_sequence_len = records[i].sequence_len;
			uchar *cur_sequence = records[i].sequence;
			for (uint32 j = lz_matches[i].length; j < cur_sequence_len; ++j)
			{
				// Symbols
				uint32 bit;
				bit_stream.GetBits(bit, Huffman_sym->GetMinLen());
				int32 h_tmp = Huffman_sym->DecodeFast(bit);
				while (h_tmp < 0)
				{
					bit_stream.GetBit(bit);
					h_tmp = Huffman_sym->Decode(bit);
				};

				cur_sequence[j] = symbols[h_tmp];
			}	
			cur_sequence[cur_sequence_len] = '\0';

			if (!extracting)
				DecodeLzMatches_Insert(lz_matcher, i);
		}
	}
	else
	{
		for (uint32 i = 0; i < rec_count; ++i)
		{
			lz_matches[i].length = 0;
			uint32 cur_sequence_len = records[i].sequence_len;
			uchar *cur_sequence = records[i].sequence;
			for (uint32 j = lz_matches[i].length; j < cur_sequence_len; ++j)
			{
				// Symbols
				uint32 bit;
				bit_stream.GetBits(bit, Huffman_sym->GetMinLen());
				int32 h_tmp = Huffman_sym->DecodeFast(bit);
				while (h_tmp < 0)
				{
					bit_stream.GetBit(bit);
					h_tmp = Huffman_sym->Decode(bit);
				};

				cur_sequence[j] = symbols[h_tmp];
			}	
			cur_sequence[cur_sequence_len] = '\0';
		}
	}
	bit_stream.FlushInputWordBuffer();
}
开发者ID:PCDS,项目名称:paraDSRC,代码行数:68,代码来源:block.cpp

示例7: ReadTitle


//.........这里部分代码省略.........
						{
							num_val = 0;
						}
					}
					else
					{
						if (cur_field.is_delta_coding)
						{
							num_val = 0;
						}
						else
						{
							num_val = prev_value[j] - cur_field.min_value;
						}
					}

					if (cur_field.is_delta_coding)
					{
						num_val += prev_value[j] + cur_field.min_delta;
					}
					else
					{
						num_val += cur_field.min_value;
					}

					cur_rec.title_len += utils::to_string(cur_rec.title+cur_rec.title_len, num_val);
					prev_value[j] = num_val;
				}
				cur_rec.AppendTitle(cur_field.sep);

				continue;
			}

			if (i > 0 && cur_field.block_desc[block_no].is_block_constant)
			{
				cur_rec.AppendTitle(records[0].title+cur_field.block_str_start, cur_field.block_str_len);
				cur_rec.AppendTitle(cur_field.sep);
				continue;
			}

			uint32 field_len;
			if (!cur_field.is_len_constant)
			{
				bit_stream.GetBits(field_len, cur_field.no_of_bits_per_len);			
				field_len += cur_field.min_len;
			}
			else
			{
				field_len = cur_field.len;
			}
			
			for (uint32 k = 0; k < field_len; ++k)
			{
				if (k < cur_field.len && cur_field.Ham_mask[k])
				{
					cur_rec.AppendTitle(cur_field.data[k]);
				}
				else
				{
					uint32 bit;
					int32 h_tmp;
					HuffmanEncoder *cur_huf = cur_field.Huffman_local[MIN(k, Superblock::MAX_FIELD_STAT_LEN)]; 

					bit_stream.GetBits(bit, cur_huf->GetMinLen());
					h_tmp = cur_huf->DecodeFast(bit);

					while (h_tmp < 0)
					{
						bit_stream.GetBit(bit);
						h_tmp = cur_huf->Decode(bit);
					};

					tmp = h_tmp;
					cur_rec.AppendTitle((uchar) tmp);
				}
			}
			if (i == 0 && cur_field.block_desc[block_no].is_block_constant)
			{
				cur_field.block_str_start = cur_rec.title_len - field_len;
				cur_field.block_str_len = field_len;
			}

			cur_rec.AppendTitle(cur_field.sep);
		}

		cur_rec.title_len--;			// do not count last '\0' symbols
		cur_rec.plus[0] = '+';
		if (cur_rec.plus_len == 1)
		{
			cur_rec.plus[1] = '\0';
		}
		else
		{
			cur_rec.plus_len = cur_rec.title_len;
			cur_rec.ExtendTo(cur_rec.plus, cur_rec.plus_size, cur_rec.title_len+2);
			std::copy(cur_rec.title+1, cur_rec.title+cur_rec.title_len, cur_rec.plus+1);
		}
	}
	bit_stream.FlushInputWordBuffer();
}
开发者ID:PCDS,项目名称:paraDSRC,代码行数:101,代码来源:block.cpp

示例8: Read


//.........这里部分代码省略.........
			FastqRecord& rec = records[i];
			bit_stream.GetBits(tmp, quality_len_bits);
			rec.quality_len = tmp;
			rec.ExtendTo(rec.quality, rec.quality_size, tmp+2);
			rec.sequence_len = tmp;
			rec.ExtendTo(rec.sequence, rec.sequence_size, tmp+2);
		}
	}
	else
	{
		for (uint32 i = 0; i < rec_count; ++i)
		{
			FastqRecord& rec = records[i];
			rec.quality_len = max_quality_length;
			rec.ExtendTo(rec.quality, rec.quality_size, max_quality_length+2);
			rec.sequence_len = global_max_sequence_length;
			rec.ExtendTo(rec.sequence, rec.sequence_size, global_max_sequence_length+2);
		}
	}

	if ((fastq_flags & FLAG_LINE_BREAKS) != 0)
	{
		uint32 line_breaks_bits;
		bit_stream.GetBits(line_breaks_bits, 5);
		uint32 tmp;

		for (uint32 i = 0; i < rec_count; ++i)
		{
			FastqRecord& rec = records[i];
			if (rec.sequence_breaks)
			{
				delete rec.sequence_breaks;
				rec.sequence_breaks = NULL;
			}

			bit_stream.GetBits(tmp, line_breaks_bits);
			while (tmp != 0)
			{
				if (!rec.sequence_breaks)
				{
					rec.sequence_breaks = new std::vector<int>;
				}
				rec.sequence_breaks->push_back(tmp);

				bit_stream.GetBits(tmp, line_breaks_bits);
			}


			if (rec.quality_breaks)
			{
				delete rec.quality_breaks;
				rec.quality_breaks = NULL;
			}
			bit_stream.GetBits(tmp, line_breaks_bits);
			while (tmp != 0)
			{
				if (!rec.quality_breaks)
				{
					rec.quality_breaks = new std::vector<int>;
				}
				rec.quality_breaks->push_back(tmp);

				bit_stream.GetBits(tmp, line_breaks_bits);
			}
		}
	}
	bit_stream.FlushInputWordBuffer();


	bool is_num_fields_constant = (fastq_flags & FLAG_CONST_NUM_FIELDS) != 0;
	ReadTitle(bit_stream, fields, n_fields, block_no, is_num_fields_constant);

	if (quality_stats_mode == QUALITY_RLE)
	{
		ReadQualityRLE(bit_stream, qualities, Huffman_qua, n_qualities, Huffman_run, max_run_len);
		MakeUnRLE();
	}
	else
	{
		bool use_trunc_h = quality_stats_mode == QUALITY_PLAIN_TRUNC;
		bool uses_const_delta = (fastq_flags & (FLAG_USE_DELTA | FLAG_DELTA_CONSTANT)) ==  (FLAG_USE_DELTA | FLAG_DELTA_CONSTANT);
		ReadQualityPlain(bit_stream, qualities, Huffman_qua, n_qualities, use_trunc_h, uses_const_delta);
	}

	bool try_lz = (fastq_flags & FLAG_TRY_LZ) != 0;
	if ((fastq_flags & FLAG_DNA_PLAIN) != 0)
	{
		ReadDNAPlain(bit_stream, lz_matcher, symbols, try_lz, extracting);
	}
	else
	{
		ReadDNAHuf(bit_stream, lz_matcher, symbols, Huffman_sym, try_lz, extracting);	// lz_matches not supported when Huffman encoding
	}

#if (D_COMPUTE_RECORDS_CRC_PER_BLOCK)
	uint32 hash;
	bit_stream.GetWord(hash);
	my_assert(hash == ComputeRecordsCrc32());
#endif
}
开发者ID:PCDS,项目名称:paraDSRC,代码行数:101,代码来源:block.cpp


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