本文整理汇总了C++中BitStream::GetBit方法的典型用法代码示例。如果您正苦于以下问题:C++ BitStream::GetBit方法的具体用法?C++ BitStream::GetBit怎么用?C++ BitStream::GetBit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitStream
的用法示例。
在下文中一共展示了BitStream::GetBit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: 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();
}
示例3: 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();
}
示例4: 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();
}
示例5: ReadTitle
// ********************************************************************************************
void Block::ReadTitle(BitStream &bit_stream, std::vector<Field> &fields, uint32 n_fields, int32 block_no, bool is_num_fields_constant)
{
prev_value.resize(n_fields);
uint32 n_fields_bits = BitStream::BitLength(n_fields);
uint32 tmp = 0;
for (uint32 i = 0; i < n_fields; ++i)
{
if (fields[i].is_constant)
continue;
prev_value[i] = 0;
if (!fields[i].is_numeric)
{
bit_stream.GetBit(tmp);
fields[i].block_desc[block_no].is_block_constant = tmp != 0;
}
else
{
bit_stream.GetBit(tmp);
if (fields[i].is_delta_coding)
{
fields[i].block_desc[block_no].is_block_delta_constant = tmp != 0;
}
else
{
fields[i].block_desc[block_no].is_block_value_constant = tmp != 0;
}
}
}
for (uint32 i = 0; i < rec_count; ++i)
{
FastqRecord& cur_rec = records[i];
uint32 cn_fields = n_fields;
if (!is_num_fields_constant)
{
bit_stream.GetBits(tmp, n_fields_bits);
cn_fields = tmp;
}
for (uint32 j = 0; j < cn_fields; ++j)
{
Field &cur_field = fields[j];
if (cur_field.is_constant)
{
cur_rec.AppendTitle(cur_field.data, cur_field.len);
cur_rec.AppendTitle(cur_field.sep);
continue;
}
if (cur_field.is_numeric)
{
uint32 num_val = 0;
if (cur_rec.title_len + 10 >= cur_rec.title_size)
{
cur_rec.Extend(cur_rec.title, cur_rec.title_size);
}
if (i == 0)
{
bit_stream.GetBits(num_val, cur_field.no_of_bits_per_value);
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;
}
else
{
if ((cur_field.is_delta_coding && !cur_field.block_desc[block_no].is_block_delta_constant) ||
(!cur_field.is_delta_coding && !cur_field.block_desc[block_no].is_block_value_constant))
{
if (cur_field.no_of_bits_per_num > 0)
{
if (cur_field.Huffman_global)
{
uint32 bit;
int32 h_tmp;
bit_stream.GetBits(bit, cur_field.Huffman_global->GetMinLen());
h_tmp = cur_field.Huffman_global->DecodeFast(bit);
while (h_tmp < 0)
{
bit_stream.GetBit(bit);
h_tmp = cur_field.Huffman_global->Decode(bit);
};
num_val = h_tmp;
}
else
{
bit_stream.GetBits(num_val, cur_field.no_of_bits_per_num);
}
}
else
{
num_val = 0;
}
}
//.........这里部分代码省略.........
示例6: Read
// ********************************************************************************************
void Block::Read(BitStream &bit_stream, LzMatcher &lz_matcher, std::vector<Field> &fields, uint32 n_fields,
uint32 fastq_flags, std::vector<uchar> &symbols, HuffmanEncoder *Huffman_sym,
std::vector<uchar> &qualities, std::vector<HuffmanEncoder*> &Huffman_qua,
uint32 max_run_len, std::vector<HuffmanEncoder*> &Huffman_run, uint32 n_qualities,
uint32 _global_max_sequence_length, uint32 max_quality_length, uint32 block_no,
uint32 quality_stats_mode, bool extracting)
{
global_max_sequence_length = _global_max_sequence_length;
#if (D_RESERVE_BYTES_PER_BLOCK)
{
uchar bytes[Block::RESERVED_BYTES];
bit_stream.GetBytes(bytes, Block::RESERVED_BYTES);
for (uint32 i = 0; i < Block::RESERVED_BYTES; ++i)
{
my_assert(bytes[i] == INVALID_BYTE);
}
}
#endif
no_of_amb.resize(rec_count);
for (uint32 i = 0; i < rec_count; ++i)
{
records[i].Reset();
no_of_amb[i] = 0;
}
int32 quality_len_bits = BitStream::BitLength(max_quality_length);
if ((fastq_flags & FLAG_PLUS_ONLY) == 0)
{
for (uint32 i = 0; i < rec_count; ++i)
{
bit_stream.GetBit(records[i].plus_len);
}
}
else
{
for (uint32 i = 0; i < rec_count; ++i)
{
records[i].plus_len = 1;
}
}
if ((fastq_flags & FLAG_VARIABLE_LENGTH) != 0)
{
uint32 tmp;
for (uint32 i = 0; i < rec_count; ++i)
{
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;
//.........这里部分代码省略.........