本文整理汇总了C++中BitStream::getBitPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ BitStream::getBitPosition方法的具体用法?C++ BitStream::getBitPosition怎么用?C++ BitStream::getBitPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitStream
的用法示例。
在下文中一共展示了BitStream::getBitPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: huffmanEncodeCPU
bool huffmanEncodeCPU(BitStream& bitStream, const std::vector<Symbol16>& symbolStream, const HuffmanEncodeTableCPU& encodeTable, std::vector<uint>& offsets, uint codingBlockSize)
{
uint offsetBase = bitStream.getBitPosition();
for(uint i = 0; i < symbolStream.size(); i++) {
if(codingBlockSize > 0 && i % codingBlockSize == 0) {
offsets.push_back(bitStream.getBitPosition() - offsetBase);
}
Symbol16 symbol = symbolStream[i];
const HuffmanEntry& entry = encodeTable.m_encodeTable[symbol];
bitStream.writeBits(entry.m_codeword, entry.m_codewordLength);
}
return true;
}
示例2: rbucEncodeCPUWriteTree
void rbucEncodeCPUWriteTree(BitStream& bitStream, std::vector<uint>& offsets, const std::vector<std::vector<Symbol16>>& tree, const std::vector<uint>& branchFactors, uint level, uint index)
{
if(level+2 == tree.size()) {
offsets.push_back(bitStream.getBitPosition());
}
uint bits = (level+1 >= tree.size() ? 8 : tree[level+1][index / branchFactors[level]]);
bitStream.writeBits(tree[level][index], bits);
if(level > 0) {
uint branchFactor = branchFactors[level - 1];
uint childrenCount = std::min(branchFactor, (uint)tree[level - 1].size() - index * branchFactor);
for(uint i = 0; i < childrenCount; i++) {
rbucEncodeCPUWriteTree(bitStream, offsets, tree, branchFactors, level - 1, index * branchFactor + i);
}
}
}
示例3: generateCodes
void HuffmanStringProcessor::generateCodes(BitStream& rBS, S32 index, S32 depth)
{
if (index < 0) {
// leaf node, copy the code in, and back out...
HuffLeaf& rLeaf = mHuffLeaves[-(index + 1)];
memcpy(&rLeaf.code, rBS.getBuffer(), sizeof(rLeaf.code));
rLeaf.numBits = depth;
} else {
HuffNode& rNode = mHuffNodes[index];
S32 pos = rBS.getBitPosition();
rBS.writeFlag(false);
generateCodes(rBS, rNode.index0, depth + 1);
rBS.setBitPosition(pos);
rBS.writeFlag(true);
generateCodes(rBS, rNode.index1, depth + 1);
rBS.setBitPosition(pos);
}
}
示例4: postNetEvent
bool EventConnection::postNetEvent(NetEvent *theEvent)
{
// Check if the direction this event moves is a valid direction.
TNLAssertV( (theEvent->getEventDirection() != NetEvent::DirUnset)
&& (theEvent->getEventDirection() != NetEvent::DirServerToClient || !isConnectionToServer())
&& (theEvent->getEventDirection() != NetEvent::DirClientToServer || !isConnectionToClient()),
("Trying to send wrong event direction in %s", theEvent->getClassName()));
S32 classId = theEvent->getClassId(getNetClassGroup());
if(U32(classId) >= mEventClassCount && getConnectionState() == Connected)
{
theEvent->incRef();
theEvent->decRef(); // Avoids some type of memory leak by deleting here if nothing reference it.
return false;
}
theEvent->notifyPosted(this);
EventNote *event = mEventNoteChunker.alloc();
event->mEvent = theEvent;
event->mNextEvent = NULL;
if(event->mEvent->mGuaranteeType == NetEvent::GuaranteedOrdered)
{
event->mSeqCount = mNextSendEventSeq++;
if(!mSendEventQueueHead)
mSendEventQueueHead = event;
else
mSendEventQueueTail->mNextEvent = event;
mSendEventQueueTail = event;
}
else if(event->mEvent->mGuaranteeType == NetEvent::GuaranteedOrderedBigData)
{
BitStream bstream;
const U32 start = 0;
const U32 partsSize = 512;
if(mConnectionParameters.mDebugObjectSizes)
bstream.advanceBitPosition(BitStreamPosBitSize);
S32 classId = event->mEvent->getClassId(getNetClassGroup());
bstream.writeInt(classId, mEventClassBitSize);
event->mEvent->pack(this, &bstream);
logprintf(LogConsumer::LogEventConnection, "EventConnection %s: WroteEvent %s - %d bits", getNetAddressString(), event->mEvent->getDebugName(), bstream.getBitPosition() - start);
if(mConnectionParameters.mDebugObjectSizes)
bstream.writeIntAt(bstream.getBitPosition(), BitStreamPosBitSize, start);
U32 size = bstream.getBytePosition();
for(U32 i=0; i<size; i+=partsSize)
{
if(i+partsSize < size)
{
ByteBuffer *bytebuffer = new ByteBuffer(&bstream.getBuffer()[i], partsSize);
bytebuffer->takeOwnership(); // may have to use this to prevent errors.
s2rTNLSendDataParts(0, ByteBufferPtr(bytebuffer));
}
else
{
ByteBuffer *bytebuffer = new ByteBuffer(&bstream.getBuffer()[i], size-i);
bytebuffer->takeOwnership();
s2rTNLSendDataParts(1, ByteBufferPtr(bytebuffer));
}
}
mEventNoteChunker.free(event);
}
else
{
event->mSeqCount = InvalidSendEventSeq;
if(!mUnorderedSendEventQueueHead)
mUnorderedSendEventQueueHead = event;
else
mUnorderedSendEventQueueTail->mNextEvent = event;
mUnorderedSendEventQueueTail = event;
}
return true;
}