History

pack more compressed sections into wire packets if there is room

ZappoMan committed 12 years ago

Commit dac211c1 parent b7ee2ea6 files · +132 −42Browse files

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

Unified · Split

interface/src/VoxelSystem.cpp+34−19
@@ -619,26 +619,41 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 618 unmodified lines
619 VOXEL_PACKET_INTERNAL_SECTION_SIZE sectionLength = 0;619 VOXEL_PACKET_INTERNAL_SECTION_SIZE sectionLength = 0;
620 int dataBytes = numBytes - VOXEL_PACKET_HEADER_SIZE;620 int dataBytes = numBytes - VOXEL_PACKET_HEADER_SIZE;
621 621
622 if (packetIsCompressed && dataBytes > sizeof(VOXEL_PACKET_INTERNAL_SECTION_SIZE)) {622 int subsection = 1;
623 sectionLength = (*(VOXEL_PACKET_INTERNAL_SECTION_SIZE*)dataAt);623 while (dataBytes > 0) {
624 dataAt += sizeof(VOXEL_PACKET_INTERNAL_SECTION_SIZE);624 if (packetIsCompressed) {
625 } else {625 if (dataBytes > sizeof(VOXEL_PACKET_INTERNAL_SECTION_SIZE)) {
626 sectionLength = dataBytes;626 sectionLength = (*(VOXEL_PACKET_INTERNAL_SECTION_SIZE*)dataAt);
627 }627 dataAt += sizeof(VOXEL_PACKET_INTERNAL_SECTION_SIZE);
628 unsigned char* voxelData = dataAt;628 dataBytes -= sizeof(VOXEL_PACKET_INTERNAL_SECTION_SIZE);
629 629 } else {
630 // ask the VoxelTree to read the bitstream into the tree630 sectionLength = 0;
631 ReadBitstreamToTreeParams args(packetIsColored ? WANT_COLOR : NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceUUID());631 dataBytes = 0; // stop looping something is wrong
632 lockTree();632 }
633 VoxelPacketData packetData(packetIsCompressed);633 } else {
634 packetData.loadFinalizedContent(voxelData, sectionLength);634 sectionLength = dataBytes;
635 if (true || Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging)) {635 }
636 qDebug("Got Packet color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%d sectionLength:%d uncompressed:%d\n",636
637 debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed), 637 if (sectionLength) {
638 sequence, flightTime, numBytes, dataBytes, sectionLength, packetData.getUncompressedSize());638 // ask the VoxelTree to read the bitstream into the tree
639 ReadBitstreamToTreeParams args(packetIsColored ? WANT_COLOR : NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceUUID());
640 lockTree();
641 VoxelPacketData packetData(packetIsCompressed);
642 packetData.loadFinalizedContent(dataAt, sectionLength);
643 if (Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging)) {
644 qDebug("Got Packet color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%d"
645 " subsection:%d sectionLength:%d uncompressed:%d\n",
646 debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed),
647 sequence, flightTime, numBytes, dataBytes, subsection, sectionLength, packetData.getUncompressedSize());
648 }
649 _tree->readBitstreamToTree(packetData.getUncompressedData(), packetData.getUncompressedSize(), args);
650 unlockTree();
651
652 dataBytes -= sectionLength;
653 dataAt += sectionLength;
654 }
639 }655 }
640 _tree->readBitstreamToTree(packetData.getUncompressedData(), packetData.getUncompressedSize(), args);656 subsection++;
641 unlockTree();
642 }657 }
643 break;658 break;
644 }659 }