History

add section size to compressed packets to allow packing of multiple sections

ZappoMan committed 12 years ago

Commit b7ee2ea1 parent 77590b54 files · +24 −7Browse files

Showing the changes to interface/src/VoxelSystem.cpp (1 of 4 files). Show all

Unified · Split

interface/src/VoxelSystem.cpp+13−6
@@ -610,25 +610,32 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 609 unmodified lines
610610 VOXEL_PACKET_SENT_TIME sentAt = (*(VOXEL_PACKET_SENT_TIME*)dataAt);
611611 dataAt += sizeof(VOXEL_PACKET_SENT_TIME);
612612
613− unsigned char* voxelData = dataAt;
614−
615613 bool packetIsColored = oneAtBit(flags, PACKET_IS_COLOR_BIT);
616614 bool packetIsCompressed = oneAtBit(flags, PACKET_IS_COMPRESSED_BIT);
617615
618616 VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow();
619617 int flightTime = arrivedAt - sentAt;
620618
619+ VOXEL_PACKET_INTERNAL_SECTION_SIZE sectionLength = 0;
621620 int dataBytes = numBytes - VOXEL_PACKET_HEADER_SIZE;
621+
622+ if (packetIsCompressed && dataBytes > sizeof(VOXEL_PACKET_INTERNAL_SECTION_SIZE)) {
623+ sectionLength = (*(VOXEL_PACKET_INTERNAL_SECTION_SIZE*)dataAt);
624+ dataAt += sizeof(VOXEL_PACKET_INTERNAL_SECTION_SIZE);
625+ } else {
626+ sectionLength = dataBytes;
627+ }
628+ unsigned char* voxelData = dataAt;
622629
623630 // ask the VoxelTree to read the bitstream into the tree
624631 ReadBitstreamToTreeParams args(packetIsColored ? WANT_COLOR : NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceUUID());
625632 lockTree();
626633 VoxelPacketData packetData(packetIsCompressed);
627− packetData.loadFinalizedContent(voxelData, dataBytes);
628− if (Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging)) {
629− qDebug("Got Packet color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%d uncompressed:%d\n",
634+ packetData.loadFinalizedContent(voxelData, sectionLength);
635+ if (true || Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging)) {
636+ qDebug("Got Packet color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%d sectionLength:%d uncompressed:%d\n",
630637 debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed),
631− sequence, flightTime, numBytes, dataBytes, packetData.getUncompressedSize());
638+ sequence, flightTime, numBytes, dataBytes, sectionLength, packetData.getUncompressedSize());
632639 }
633640 _tree->readBitstreamToTree(packetData.getUncompressedData(), packetData.getUncompressedSize(), args);
634641 unlockTree();