cleanup for coding standard

This commit is contained in:
ZappoMan 2013-11-24 15:22:44 -08:00
parent 94584d4ead
commit 25511f99ec
6 changed files with 30 additions and 26 deletions

View file

@ -599,8 +599,10 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
lockTree(); lockTree();
VoxelPacket packet(VOXEL_PACKET_COMPRESSION_DEFAULT); VoxelPacket packet(VOXEL_PACKET_COMPRESSION_DEFAULT);
int compressedSize = numBytes - numBytesPacketHeader; int compressedSize = numBytes - numBytesPacketHeader;
packet.loadCompressedContent(voxelData, compressedSize); packet.loadFinalizedContent(voxelData, compressedSize);
printf("got packet numBytes=%d compressed size %d uncompressed size %d\n",numBytes, compressedSize, packet.getUncompressedSize()); if (Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging)) {
qDebug("got packet numBytes=%d finalized size %d uncompressed size %d\n",numBytes, compressedSize, packet.getUncompressedSize());
}
_tree->readBitstreamToTree(packet.getUncompressedData(), packet.getUncompressedSize(), args); _tree->readBitstreamToTree(packet.getUncompressedData(), packet.getUncompressedSize(), args);
unlockTree(); unlockTree();
} }
@ -613,8 +615,10 @@ printf("got packet numBytes=%d compressed size %d uncompressed size %d\n",numByt
lockTree(); lockTree();
VoxelPacket packet(VOXEL_PACKET_COMPRESSION_DEFAULT); VoxelPacket packet(VOXEL_PACKET_COMPRESSION_DEFAULT);
int compressedSize = numBytes - numBytesPacketHeader; int compressedSize = numBytes - numBytesPacketHeader;
packet.loadCompressedContent(voxelData, compressedSize); packet.loadFinalizedContent(voxelData, compressedSize);
printf("got packet numBytes=%d compressed size %d uncompressed size %d\n",numBytes, compressedSize, packet.getUncompressedSize()); if (Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging)) {
qDebug("got packet numBytes=%d finalized size %d uncompressed size %d\n",numBytes, compressedSize, packet.getUncompressedSize());
}
_tree->readBitstreamToTree(packet.getUncompressedData(), packet.getUncompressedSize(), args); _tree->readBitstreamToTree(packet.getUncompressedData(), packet.getUncompressedSize(), args);
unlockTree(); unlockTree();
} }

View file

@ -32,12 +32,12 @@ int numberOfThreeBitSectionsInCode(const unsigned char* octalCode, int maxBytes)
void printOctalCode(const unsigned char* octalCode) { void printOctalCode(const unsigned char* octalCode) {
if (!octalCode) { if (!octalCode) {
printf("NULL\n"); qDebug("NULL\n");
} else { } else {
for (int i = 0; i < bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(octalCode)); i++) { for (int i = 0; i < bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(octalCode)); i++) {
outputBits(octalCode[i],false); outputBits(octalCode[i],false);
} }
printf("\n"); qDebug("\n");
} }
} }

View file

@ -71,18 +71,18 @@ void outputBufferBits(const unsigned char* buffer, int length, bool withNewLine)
void outputBits(unsigned char byte, bool withNewLine) { void outputBits(unsigned char byte, bool withNewLine) {
if (isalnum(byte)) { if (isalnum(byte)) {
printf("[ %d (%c): ", byte, byte); qDebug("[ %d (%c): ", byte, byte);
} else { } else {
printf("[ %d (0x%x): ", byte, byte); qDebug("[ %d (0x%x): ", byte, byte);
} }
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
printf("%d", byte >> (7 - i) & 1); qDebug("%d", byte >> (7 - i) & 1);
} }
printf(" ] "); qDebug(" ] ");
if (withNewLine) { if (withNewLine) {
printf("\n"); qDebug("\n");
} }
} }

View file

@ -374,15 +374,7 @@ int VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* nod
_myServer->getServerTree().lockForRead(); _myServer->getServerTree().lockForRead();
nodeData->stats.encodeStarted(); nodeData->stats.encodeStarted();
//printf("calling nodeBag.count()=%d encode()... subTree=%p \n", nodeData->nodeBag.count(), subTree);
//printOctalCode(subTree->getOctalCode());
bytesWritten = _myServer->getServerTree().encodeTreeBitstream(subTree, &_tempPacket, nodeData->nodeBag, params); bytesWritten = _myServer->getServerTree().encodeTreeBitstream(subTree, &_tempPacket, nodeData->nodeBag, params);
//printf("called encode()... bytesWritten=%d compressedSize=%d uncompressedSize=%d\n",bytesWritten, _tempPacket.getFinalizedSize(), _tempPacket.getUncompressedSize());
if (bytesWritten > 0) { if (bytesWritten > 0) {
_encodedSomething = true; _encodedSomething = true;
} }
@ -399,7 +391,10 @@ int VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* nod
// mean we should send the previous packet contents and reset it. // mean we should send the previous packet contents and reset it.
bool sendNow = (bytesWritten == 0); bool sendNow = (bytesWritten == 0);
if (_tempPacket.hasContent() && sendNow) { if (_tempPacket.hasContent() && sendNow) {
//printf("calling writeToPacket() compressedSize=%d uncompressedSize=%d\n",_tempPacket.getFinalizedSize(), _tempPacket.getUncompressedSize()); if (_myServer->wantsDebugVoxelSending() && _myServer->wantsVerboseDebug()) {
printf("calling writeToPacket() compressedSize=%d uncompressedSize=%d\n",
_tempPacket.getFinalizedSize(), _tempPacket.getUncompressedSize());
}
nodeData->writeToPacket(_tempPacket.getFinalizedData(), _tempPacket.getFinalizedSize()); nodeData->writeToPacket(_tempPacket.getFinalizedData(), _tempPacket.getFinalizedSize());
packetsSentThisInterval += handlePacketSend(node, nodeData, trueBytesSent, truePacketsSent); packetsSentThisInterval += handlePacketSend(node, nodeData, trueBytesSent, truePacketsSent);
_tempPacket.reset(); _tempPacket.reset();

View file

@ -147,15 +147,19 @@ int VoxelPacket::startLevel() {
void VoxelPacket::discardLevel(int key) { void VoxelPacket::discardLevel(int key) {
int bytesInLevel = _bytesInUse - key; int bytesInLevel = _bytesInUse - key;
if (_debug) printf("discardLevel() BEFORE _dirty=%s bytesInLevel=%d _compressedBytes=%d _bytesInUse=%d\n", if (_debug) {
printf("discardLevel() BEFORE _dirty=%s bytesInLevel=%d _compressedBytes=%d _bytesInUse=%d\n",
debug::valueOf(_dirty), bytesInLevel, _compressedBytes, _bytesInUse); debug::valueOf(_dirty), bytesInLevel, _compressedBytes, _bytesInUse);
}
_bytesInUse -= bytesInLevel; _bytesInUse -= bytesInLevel;
_bytesAvailable += bytesInLevel; _bytesAvailable += bytesInLevel;
_dirty = true; _dirty = true;
if (_debug) printf("discardLevel() AFTER _dirty=%s bytesInLevel=%d _compressedBytes=%d _bytesInUse=%d\n", if (_debug) {
printf("discardLevel() AFTER _dirty=%s bytesInLevel=%d _compressedBytes=%d _bytesInUse=%d\n",
debug::valueOf(_dirty), bytesInLevel, _compressedBytes, _bytesInUse); debug::valueOf(_dirty), bytesInLevel, _compressedBytes, _bytesInUse);
}
} }
bool VoxelPacket::endLevel(int key) { bool VoxelPacket::endLevel(int key) {
@ -235,7 +239,7 @@ bool VoxelPacket::checkCompress() {
} }
void VoxelPacket::loadCompressedContent(const unsigned char* data, int length) { void VoxelPacket::loadFinalizedContent(const unsigned char* data, int length) {
reset(); // by definition we reset upon loading compressed content reset(); // by definition we reset upon loading compressed content
if (length > 0) { if (length > 0) {

View file

@ -6,9 +6,10 @@
// //
// TO DO: // TO DO:
// //
// * improve compression to be less expensive (mostly determine when to test compression...) // * further testing of compression to determine optimal configuration for performance and compression
// //
// * add stats tracking for number of bytes of octal code, bitmasks, and colors in a packet. // * add stats tracking for number of bytes of octal code, bitmasks, and colors in a packet.
//
// * improve semantics for "reshuffle" - current approach will work for now and with compression // * improve semantics for "reshuffle" - current approach will work for now and with compression
// but wouldn't work with RLE because the colors in the levels would get reordered and RLE would need // but wouldn't work with RLE because the colors in the levels would get reordered and RLE would need
// to be recalculated // to be recalculated
@ -82,8 +83,8 @@ public:
/// has some content been written to the packet /// has some content been written to the packet
bool hasContent() const { return (_bytesInUse > 0); } bool hasContent() const { return (_bytesInUse > 0); }
/// load compressed content to allow access to decoded content for parsing /// load finalized content to allow access to decoded content for parsing
void loadCompressedContent(const unsigned char* data, int length); void loadFinalizedContent(const unsigned char* data, int length);
void debugContent(); void debugContent();