Exemple #1
0
void TsPacket::input_bitstream(Bitstream & bitstream)
{
	//bitstream.print_packet();

    data_packet_start_byte_offset = bitstream.get_in_byte_offset();
    ts_packet_size = bitstream.get_ts_packet_size();

//    level1_timer->start();
    tsheader->input_bitstream(bitstream);
//    level1_timer->stop();

    pid = tsheader->get_PID();
    payload_unit_start_indicator = tsheader->get_PUSI();
    adaptation_field_control = tsheader->get_adapation_flag();

    if(adaptation_field_control == 0x2 || adaptation_field_control == 0x3)
    {
//    	level2_timer->start();
		int start_offset = bitstream.get_in_byte_offset();
		adaptation_header->input_bitstream(bitstream);
		int length = adaptation_header->get_length();
		bitstream.skip_bytes(start_offset, length + LENGTH_VAR_BYTES);
//		level2_timer->stop();
	}
}
Exemple #2
0
uint32_t read_entity_header(uint32_t *base, Bitstream &stream) {
  uint32_t value = stream.get_bits(6);

  if (value & 0x30) {
    uint32_t a = (value >> 4) & 3;
    uint32_t b = (a == 3) ? 16 : 0;

    value = stream.get_bits(4 * a + b) << 4 | (value & 0xF);
  }
void IncomingMessageQueue::deserializeAndNotify(unsigned short cur_pos) {
	boost::mutex::scoped_lock lock(_mutex);

	Header* header = new Header(_messageQueue[cur_pos].header);
	Bitstream* bitstream = new Bitstream(_messageQueue[cur_pos].bitstream);

	_lastSeqNumCompleted->at(_lastSeqNumQueueIdx) = header->getSeqNum();
	++_lastSeqNumQueueIdx;
	if (_lastSeqNumQueueIdx == _lastSeqNumQueueLength) {
		_lastSeqNumQueueIdx = 0;
	}

	Message* msg = NULL;

	if (_DEBUG)
		cout
				<< "IncomingMessageQueue::deserializeAndNotify: bitstream->size() = "
				<< bitstream->size() << endl;

	msg = MessageParser::parseMessage(header, bitstream);

	if (msg != NULL) {
		double rxTime = (_messageQueue[cur_pos].endTime
				- _messageQueue[cur_pos].startTime) / cv::getTickFrequency();

		switch (_messageQueue[cur_pos].header.getMsgType()) {
		case MESSAGETYPE_DATA_CTA: {
			((DataCTAMsg*) (msg))->setTxTime(rxTime);
			break;
		}
		case MESSAGETYPE_DATA_ATC: {
			((DataATCMsg*) (msg))->setTxTime(rxTime);
			break;
		}
		default:
			break;
		}

		_nodeNetworkSystem->telosMessageHandler(msg);

	}

//erase the entry from the message queue once notified
	if (_DEBUG)
		cout << "IncomingMessageQueue::deserializeAndNotify: erasing entry"
				<< endl;
	_messageQueue.erase(_messageQueue.begin() + cur_pos);
	if (_DEBUG)
		cout << "IncomingMessageQueue::deserializeAndNotify: entry erased"
				<< endl;

}
Exemple #4
0
void MetavoxelData::write(Bitstream& out) const {
    out << _size;
    out << _roots.size();
    for (QHash<AttributePointer, MetavoxelNode*>::const_iterator it = _roots.constBegin(); it != _roots.constEnd(); it++) {
        out.getAttributeStreamer() << it.key();
        it.value()->write(it.key(), out);
    }
}
Exemple #5
0
void MetavoxelData::readDelta(const MetavoxelData& reference, Bitstream& in) {
    // shallow copy the reference
    *this = reference;

    bool changed;
    in >> changed;
    if (!changed) {
        return;
    }

    bool sizeChanged;
    in >> sizeChanged;
    if (sizeChanged) {
        float size;
        in >> size;
        while (_size < size) {
            expand();
        }
    }

    int changedCount;
    in >> changedCount;
    for (int i = 0; i < changedCount; i++) {
        AttributePointer attribute;
        in.getAttributeStreamer() >> attribute;
        MetavoxelNode*& root = _roots[attribute];
        if (root) {
            MetavoxelNode* oldRoot = root;
            root = new MetavoxelNode(attribute);
            root->readDelta(attribute, *oldRoot, in);
            oldRoot->decrementReferenceCount(attribute);
            
        } else {
            root = new MetavoxelNode(attribute);
            root->read(attribute, in);
        } 
    }
    
    int removedCount;
    in >> removedCount;
    for (int i = 0; i < removedCount; i++) {
        AttributePointer attribute;
        in.getAttributeStreamer() >> attribute;
        _roots.take(attribute)->decrementReferenceCount(attribute);
    }
}
void test_poke_normal_case(const Bitstream& original,
                           const Bitstream& changed,
                           const int exit_code,
                           const uint64_t value,
                           const size_t start,
                           const size_t length)
{

    Bitstream max_value(length);

    max_value.set();

    if (start + length > original.size())
    {
        assert(original == changed);
        assert(exit_code == -1);
    }
    else if(value > max_value.to_ulong())
    {
        assert(original == changed);
        assert(exit_code == -2);
    }
    else
    {
        Bitstream sequence(length, value);

        Bitstream cpy = original;

        for(size_t i = 0; i < sequence.size(); i++)
        {
            size_t pos = (cpy.size() - start - length) + i;
            cpy[pos] = sequence[i];
        }

        assert(cpy == changed);
        assert(exit_code == 0);

        for(size_t  i = cpy.size()-start;  i < cpy.size(); i++)
            assert(original[i] == cpy[i]);

        for(size_t  i = cpy.size()-start-length; i < cpy.size()-start; i++)
            assert(changed[i] == cpy[i]);

        for(size_t  i = 0;  i < cpy.size()-start-length; i++)
            assert(original[i] == cpy[i]);
    }
}
Exemple #7
0
HeightfieldData::HeightfieldData(Bitstream& in, int bytes, bool color) :
    _encoded(in.readAligned(bytes)) {
    
    QImage image = QImage::fromData(_encoded).convertToFormat(QImage::Format_RGB888);
    if (color) {
        _contents.resize(image.width() * image.height() * BYTES_PER_PIXEL);
        memcpy(_contents.data(), image.constBits(), _contents.size());
        
    } else {
        _contents.resize(image.width() * image.height());
        char* dest = _contents.data();
        for (const uchar* src = image.constBits(), *end = src + _contents.size() * BYTES_PER_PIXEL;
                src != end; src += BYTES_PER_PIXEL) {
            *dest++ = *src;
        }
    }
}
Exemple #8
0
void MetavoxelData::read(Bitstream& in) {
    // clear out any existing roots
    decrementRootReferenceCounts();
    _roots.clear();

    in >> _size;
    
    // read in the new roots
    int rootCount;
    in >> rootCount;
    for (int i = 0; i < rootCount; i++) {
        AttributePointer attribute;
        in.getAttributeStreamer() >> attribute;
        MetavoxelNode*& root = _roots[attribute];
        root = new MetavoxelNode(attribute);
        root->read(attribute, in);
    }
}
    // equals operator
    bool Bitstream::operator==( const Bitstream& stream ) const
    {
        if( ByteLength() != stream.ByteLength() )
            return false;

        if( mFront != stream.mFront )
            return false;

        std::vector<uint8_t>::const_iterator my_itr     = mStream.begin();
        std::vector<uint8_t>::const_iterator my_end     = mStream.end();
        std::vector<uint8_t>::const_iterator stream_itr = stream.mStream.begin();

        for( ; my_itr != my_end; ++my_itr, ++stream_itr )
        {
            if( *my_itr != *stream_itr )
                return false;
        }

        return true;
    }
Exemple #10
0
void HeightfieldData::write(Bitstream& out, bool color) {
    QMutexLocker locker(&_encodedMutex);
    if (_encoded.isEmpty()) {
        QImage image;        
        if (color) {    
            int size = glm::sqrt(_contents.size() / (float)BYTES_PER_PIXEL);
            image = QImage((uchar*)_contents.data(), size, size, QImage::Format_RGB888);
        } else {
            int size = glm::sqrt((float)_contents.size());
            image = QImage(size, size, QImage::Format_RGB888);
            uchar* dest = image.bits();
            for (const char* src = _contents.constData(), *end = src + _contents.size(); src != end; src++) {
                *dest++ = *src;
                *dest++ = *src;
                *dest++ = *src;
            }
        }
        QBuffer buffer(&_encoded);
        buffer.open(QIODevice::WriteOnly);
        image.save(&buffer, "JPG");
    }
    out << _encoded.size();
    out.writeAligned(_encoded);
}
void Session::_sendMessageThread() {
	if (_DEBUG)
		cout << "Session::_sendMessageThread" << endl;

	Message* msg;
	double time;

	while (1) {
		_messagesQueue.wait_and_pop(msg);
		if (_deleted) {
			if (_DEBUG)
				cout << "Session::_sendMessageThread: deleted thread" << endl;
			break;
		}

		if (_DEBUG)
			cout << "Session::_sendMessageThread: Message: " << *msg << endl;

		/*
		 * If Camera set DataATC and DataCTA txTime from previous measurements
		 */
		switch (NetworkNode::getMyself()->getType()) {
		case NODETYPE_CAMERA: {
			switch (msg->getType()) {
			case MESSAGETYPE_DATA_ATC: {
				if (_DEBUG)
					cout
							<< "Session::_sendMessageThread: setting ATC send time: "
							<< _txTimeATC << endl;
				((DataATCMsg*) msg)->setTxTime(_txTimeATC);
				break;
			}
			case MESSAGETYPE_DATA_CTA: {
				if (_DEBUG)
					cout
							<< "Session::_sendMessageThread: setting CTA send time: "
							<< _txTimeCTA << endl;
				((DataCTAMsg*) msg)->setTxTime(_txTimeCTA);
				break;
			}
			default:
				break;
			}
			break;
		}
		default:
			break;
		}

		time = cv::getCPUTickCount();
		Bitstream* msgBitstream = msg->getBitStream();
		if (_DEBUG > 2)
			cout << "Session::_sendMessageThread: message serialization time: "
					<< (cv::getCPUTickCount() - time) / cv::getTickFrequency()
					<< " - message bitstream length: " << msgBitstream->size()
					<< " byte" << endl;

		Header header(msg->getSrc(), msg->getDst(), msg->getSeqNum(), 1, 0,
				msg->getType(), msg->getLinkType(), msgBitstream->size());

		bool notifySendEnd = msg->getType() == MESSAGETYPE_DATA_ATC
				|| msg->getType() == MESSAGETYPE_DATA_CTA;

		delete msg;

		time = cv::getCPUTickCount();
		Bitstream* headerBitstream = header.serializeForIpPacket();
		if (_DEBUG > 2)
			cout
					<< "Session::_sendMessageThread: IP header serialization time: "
					<< (cv::getCPUTickCount() - time) / cv::getTickFrequency()
					<< endl;

		vector<unsigned char> outputBitstream;
		outputBitstream.reserve(headerBitstream->size() + msgBitstream->size());
		outputBitstream.insert(outputBitstream.end(), headerBitstream->begin(),
				headerBitstream->end());
		outputBitstream.insert(outputBitstream.end(), msgBitstream->begin(),
				msgBitstream->end());

		boost::system::error_code error;

		write(*_socket,
				boost::asio::buffer(outputBitstream, outputBitstream.size()),
				error);

		delete msgBitstream;

#ifndef GUI
		if (notifySendEnd)
			NodeNetworkSystem::messageSent();
#endif
		if (error) {
			_interface->errorHandler(this, error);
			return;
		}
	}

	if (_DEBUG)
		cout << "Session::_sendMessageThread: End" << endl;

}
/*
 * The provided header is first copied and then deleted
 */
void IncomingMessageQueue::addPacketToQueue(Header* header,
		const Bitstream& packetBitstream) {
	if (_DEBUG)
		cout << "IncomingMessageQueue::addPacketToQueue" << endl;

	boost::mutex::scoped_lock lock(_mutex);
	unsigned int queueIdx;

	if (_DEBUG)
		cout << "IncomingMessageQueue::addPacketToQueue: header: " << *header
				<< endl;

	/*
	 * If the newly arrived packet sequence number has been already deserialized it is ignored
	 */
	bool seqNumberAlreadyProcessed = false;
	for (unsigned char idx = 0; idx < _lastSeqNumQueueLength; ++idx) {
		if (_lastSeqNumCompleted->at(idx) == header->getSeqNum()) {
			seqNumberAlreadyProcessed = true;
			break;
		}
	}
	if (seqNumberAlreadyProcessed) {
		cout << "IncomingMessageQueue::addPacketToQueue: duplicate seq num. Ignoring the packet."
				<< endl;
	} else {
		/*
		 * Find a queue entry with the same sequence number as the newly arrived packet.
		 */
		for (queueIdx = 0; queueIdx < _messageQueue.size(); ++queueIdx) {
			if (header->getSeqNum()
					== _messageQueue[queueIdx].header.getSeqNum()) {
				break;
			}
		}

		if (queueIdx == _messageQueue.size()) {
			/*
			 * Create a new queue entry
			 */
			message_queue_entry newEntry;
			newEntry.header = *header;
			newEntry.lastPacketIdx = header->getPacketIdx();
			newEntry.bitstream.insert(newEntry.bitstream.begin(),
					packetBitstream.begin(), packetBitstream.end());
			newEntry.startTime = cv::getTickCount();
			if (newEntry.lastPacketIdx == 0) {
				if (_DEBUG)
					cout
							<< "IncomingMessageQueue::addPacketToQueue: create a new entry"
							<< endl;
				_messageQueue.push_back(newEntry);

				/* If the total number of packets is  */
				if (header->getNumPackets() == 1) {
					_messageQueue[queueIdx].endTime = cv::getTickCount();
					_mutex.unlock();
					deserializeAndNotify(_messageQueue.size() - 1);
				}
			} else {
				if (_DEBUG)
					cout
							<< "IncomingMessageQueue::addPacketToQueue: Lost first packet of the message, dropping this packet "
							<< endl;
			}
		} else {
			/*
			 * Append packet bitstream to the right queue entry
			 */
			int last_packet_id = _messageQueue[queueIdx].lastPacketIdx;

			if (header->getPacketIdx() == last_packet_id + 1) {
				/*
				 * Packets order respected
				 */
				if (_DEBUG)
					cout << "IncomingMessageQueue::addPacketToQueue: adding";
				_messageQueue[queueIdx].bitstream.insert(
						_messageQueue[queueIdx].bitstream.end(),
						packetBitstream.begin(), packetBitstream.end());
				if (_DEBUG)
					cout << " packet";
				_messageQueue[queueIdx].lastPacketIdx++;
				if (_DEBUG)
					cout << " to the queue" << endl;

				if (header->getPacketIdx() == header->getNumPackets() - 1) {
					_messageQueue[queueIdx].endTime = cv::getTickCount();
					_mutex.unlock();
					deserializeAndNotify(queueIdx);
				}
			} else {
				/*
				 * Packets order wrong
				 */
				if (_DEBUG)
					cout
							<< "IncomingMessageQueue::addPacketToQueue: not adding packet to the queue: ";
				if (header->getPacketIdx() == last_packet_id) {
					if (_DEBUG)
						cout << "duplicate packet" << endl;
				}
				if (header->getPacketIdx() > last_packet_id + 1) {
					if (_DEBUG)
						cout << "packet out of order" << endl;
				}
			}
		}
	}
	delete header;
}
Exemple #13
0
void SpannerPackedNormalAttribute::read(Bitstream& in, void*& value, bool isLeaf) const {
    value = getDefaultValue();
    in.read(&value, 32);
}
Exemple #14
0
void SpannerPackedNormalAttribute::write(Bitstream& out, void* value, bool isLeaf) const {
    out.write(&value, 32);
}
Exemple #15
0
void genTinyFontUpperCase()
{
	pp_uint32 x,y,i,j,k;

	Bitstream* bitstream = new Bitstream(tinyFont, (6*5*256)/8);
	bitstream->clear();
	
	k = 0;
	for (i = 'A'; i <= 'Z'; i++)
	{
		CONVERT_TINY_CHAR;
	}
	pp_uint32 l = k;
	k = 0;
	for (i = 'a'; i <= 'z'; i++)
	{
		CONVERT_TINY_CHAR;
	}
	k+=l;
	for (i = '0'; i <= '9'; i++)
	{
		CONVERT_TINY_CHAR;
	}
	
	
	i = '-';
	CONVERT_TINY_CHAR;
	
	i = '+';
	CONVERT_TINY_CHAR;
	
	i = '=';
	CONVERT_TINY_CHAR;
	
	i = '^';
	CONVERT_TINY_CHAR;
	
	i = '#';
	CONVERT_TINY_CHAR;
	
	i = '>';
	CONVERT_TINY_CHAR;
	
	i = '<';
	CONVERT_TINY_CHAR;
	
	i = 0xf4;
	CONVERT_TINY_CHAR;
	
	i = 0xfd;
	CONVERT_TINY_CHAR;
	
	i = 0xfe;
	CONVERT_TINY_CHAR;
	
	i = 239;
	CONVERT_TINY_CHAR;				
	i = 240;
	CONVERT_TINY_CHAR;					
	i = 241;
	CONVERT_TINY_CHAR;
	i = 242;
	CONVERT_TINY_CHAR;
	i = 243;
	CONVERT_TINY_CHAR;
	
	i = '.';
	CONVERT_TINY_CHAR;
	
	i = '/';
	CONVERT_TINY_CHAR;

	i = '%';
	CONVERT_TINY_CHAR;

	i = ':';
	CONVERT_TINY_CHAR;

	delete bitstream;
	
	XMFile f("TINY_UPPERCASE.6x5", true);
	
	f.write(tinyFont, 1, sizeof(tinyFont));
}
Exemple #16
0
void SpannerQRgbAttribute::write(Bitstream& out, void* value, bool isLeaf) const {
    out.write(&value, 32);
}
Exemple #17
0
void MetavoxelData::writeDelta(const MetavoxelData& reference, Bitstream& out) const {
    // first things first: there might be no change whatsoever
    if (_size == reference._size && _roots == reference._roots) {
        out << false;
        return;
    }
    out << true;
    
    // compare the size; if changed (rare), we must compare to the expanded reference
    const MetavoxelData* expandedReference = &reference;
    if (_size == reference._size) {
        out << false;
    } else {
        out << true;
        out << _size;
        
        MetavoxelData* expanded = new MetavoxelData(reference);
        while (expanded->_size < _size) {
            expanded->expand();
        }
        expandedReference = expanded;
    }

    // count the number of roots added/changed, then write
    int changedCount = 0;
    for (QHash<AttributePointer, MetavoxelNode*>::const_iterator it = _roots.constBegin(); it != _roots.constEnd(); it++) {
        MetavoxelNode* referenceRoot = expandedReference->_roots.value(it.key());
        if (it.value() != referenceRoot) {
            changedCount++;
        }
    }
    out << changedCount;
    for (QHash<AttributePointer, MetavoxelNode*>::const_iterator it = _roots.constBegin(); it != _roots.constEnd(); it++) {
        MetavoxelNode* referenceRoot = expandedReference->_roots.value(it.key());
        if (it.value() != referenceRoot) {
            out.getAttributeStreamer() << it.key();
            if (referenceRoot) {
                it.value()->writeDelta(it.key(), *referenceRoot, out);
            } else {
                it.value()->write(it.key(), out);
            }
        }
    }
    
    // same with nodes removed
    int removedCount = 0;
    for (QHash<AttributePointer, MetavoxelNode*>::const_iterator it = expandedReference->_roots.constBegin();
            it != expandedReference->_roots.constEnd(); it++) {
        if (!_roots.contains(it.key())) {
            removedCount++;
        }
    }
    out << removedCount;
    for (QHash<AttributePointer, MetavoxelNode*>::const_iterator it = expandedReference->_roots.constBegin();
            it != expandedReference->_roots.constEnd(); it++) {
        if (!_roots.contains(it.key())) {
            out.getAttributeStreamer() << it.key();
        }
    }
    
    // delete the expanded reference if we had to expand
    if (expandedReference != &reference) {
        delete expandedReference;
    }
}
void ParseAdaptationField::input_bitstream(Bitstream &bitstream)
{
	adaptation_field_length = bitstream.read_bits(8);
	log4c_category_log(mycat, LOG4C_PRIORITY_INFO, "adaptation_field_length %d", adaptation_field_length);

	if(adaptation_field_length > 0)
	{
		discontinuity_indicator = (bool)bitstream.read_bits(1);
		random_access_indicator = (bool)bitstream.read_bits(1);
		elementary_stream_priority_indicator = (bool)bitstream.read_bits(1);
		PCR_flag = (bool)bitstream.read_bits(1);
		OPCR_flag = (bool)bitstream.read_bits(1);
		splicing_point_flag = (bool)bitstream.read_bits(1);
		transport_private_data_flag = (bool)bitstream.read_bits(1);
		adaptation_field_extension_flag = (bool)bitstream.read_bits(1);
		//log4c_category_log(mycat, LOG4C_PRIORITY_TRACE, "adaptation_field_extension_flag %d", adaptation_field_extension_flag);

		if(PCR_flag)
		{
			log4c_category_log(mycat, LOG4C_PRIORITY_TRACE, "pcr flag related parsing");
			program_clock_reference_base = bitstream.read_bits(32) << 1;
			program_clock_reference_base |= (bitstream.read_bits(1));
			bitstream.skip_bits(6);
			program_clock_refrence_extension = bitstream.read_bits(9);
		}

		if(OPCR_flag)
		{
			log4c_category_log(mycat, LOG4C_PRIORITY_TRACE, "opcr flag related parsing");
			original_program_clock_reference_base = bitstream.read_bits(32) << 1;
			original_program_clock_reference_base |= (bitstream.read_bits(1));
			bitstream.skip_bits(6);
			original_program_clock_refrence_extension = bitstream.read_bits(9);
		}

		if(splicing_point_flag)
		{
			log4c_category_log(mycat, LOG4C_PRIORITY_TRACE, "splice flag related parsing");
			splice_countdown = bitstream.read_bits(8);
		}

		if(transport_private_data_flag)
		{
			log4c_category_log(mycat, LOG4C_PRIORITY_TRACE, "transport private flag related parsing");

			transport_private_data_length = bitstream.read_bits(8);
			for(int i = 0; i < transport_private_data_length; i++)
			{
				private_data_byte.push_back((char)bitstream.read_bits(8));
			}
		}

		if(adaptation_field_extension_flag)
		{
			log4c_category_log(mycat, LOG4C_PRIORITY_TRACE, "extension flag related parsing");

			adaptation_field_extension_length = bitstream.read_bits(8);
			ltw_flag = bitstream.read_bits(1);
			piecewise_rate_flag = bitstream.read_bits(1);
			seamless_splice_flag = bitstream.read_bits(1);
			bitstream.skip_bits(5);

			if(ltw_flag)
			{
				ltw_valid_flag = bitstream.read_bits(1);
				ltw_offset = bitstream.read_bits(15);
			}

			if(piecewise_rate_flag)
			{
				bitstream.skip_bits(2);
				piecewise_rate = bitstream.read_bits(22);
			}

			if(seamless_splice_flag)
			{
				splice_type = bitstream.read_bits(4);
				DTS_next_AU = bitstream.read_bits(3) << 30;
				bitstream.skip_bits(1);
				DTS_next_AU |= (bitstream.read_bits(15) << 15);
				bitstream.skip_bits(1);
				DTS_next_AU |= bitstream.read_bits(15);
				bitstream.skip_bits(1);
			}
		}
		//int bits_remaining = adaptation_field_length - start_offset;
		//log4c_category_log(mycat, LOG4C_PRIORITY_INFO, "skip_bits %d", bits_remaining);
		//bitstream.skip_bits(bits_remaining);
	}
}
DeviceID::ID_t bil::detectV5DeviceType(Bitstream& bitstream)
{
    V5BitstreamDeviceDetector deviceDetector;
    bitstream.runVisitor(deviceDetector);
    return deviceDetector.deviceID();
}
Exemple #20
0
int main(int argc, char** argv)
{
    try
    {
        //======================================================================
        // process given command line
        std::cout << SPLASH_MSG;
        parseCommandLine(argc, argv);


        //======================================================================
        // parse XDL file
        Design design;
        Device device;
        std::string devicePackageName;
        {
            // open XDL file and parse its header
            std::cout << PARSING_XDL_HEADER_MSG;
            XDLParser parser;
            std::ifstream xdlInputStream(xdlFileName.c_str());
            parser.parseHeader(xdlInputStream, design);
            devicePackageName = removeSpeed((design.deviceName()).c_str());

            // load device file of corresponding device
            std::cout << LOADING_DEVICE1_MSG << devicePackageName << LOADING_DEVICE2_MSG;
            std::string deviceFileName = dataPathName + devicePackageName + DEVICE_FILE_EXT;
            std::ifstream deviceInputStream(deviceFileName.c_str(), std::ios::binary);
            readBinary(device, deviceInputStream);

            // parse XDL
            std::cout << PARSING_XDL_MSG;
            parser.parseBody(device);
        }

        //======================================================================
        // load configuration tile map
        V5CfgTileMap cfgTileMap;
        {
            std::cout << LOADING_CFGTILEMAP_MSG;
            std::string mapFileName = dataPathName + devicePackageName + MAP_FILE_EXT;
            std::ifstream mapInputStream(mapFileName.c_str(), std::ios::binary);
            readBinary(cfgTileMap, mapInputStream);
        }

        //======================================================================
        // get configuration data from bitstream
        V5AddressLayoutRegistry addressLayoutRegistry;
        V5PacketProcessor packetProcessor(addressLayoutRegistry);
        V5Configuration& configuration = packetProcessor.configuration();
        {
            // load bitfile
            std::cout << LOADING_BITFILE_MSG;
            BitFileData bfd;
            std::ifstream bitfileStream(bitFileName.c_str(), std::ios::binary);
            readBitfile(bfd, bitfileStream);

            // construct bitstream from bitfile raw data
            std::cout << DECODING_BITSTREAM_MSG;
            Bitstream bs;
            readV5Bitstream(bs, bfd.bitstreamWords(), bfd.bitstreamWordCount());
            bfd.bitstreamWordCount(0);

            // read in available devices
            std::cout << LOADING_DEVICELIST_MSG;
            std::string deviceListFileName = dataPathName + V5DEVICES_FILENAME;
            std::ifstream lstFileStream(deviceListFileName.c_str(), std::ios::binary);
            DeviceRegistry deviceRegistry;
            readBinary(deviceRegistry, lstFileStream);

            // load address layout
            std::string deviceName = removePackageAndSpeed(devicePackageName.c_str());
            std::cout << LOADING_ADDRESSLAYOUT1_MSG << deviceName << LOADING_ADDRESSLAYOUT2_MSG;
            V5AddressLayout addressLayout;
            std::string calFileName = dataPathName + deviceName + CAL_FILE_EXT;
            std::ifstream calFileStream(calFileName.c_str(), std::ios::binary);
            readBinary(addressLayout, calFileStream);
            DeviceID::ID_t deviceID = deviceRegistry.lookup(deviceName);
            addressLayoutRegistry.insert(deviceID, addressLayout);

            // execute bitstream
            std::cout << EXECUTING_BITSTREAM_MSG;
            bs.runVisitor(packetProcessor);
        }


        //======================================================================
        // do correlation
        DeviceCfgDb cfgDatabase;
        std::cout << DOING_CORRELATION_MSG;
        {
            Correlator correlator;
            V5CfgExtractor cfgExtractor(configuration, cfgTileMap);
            correlator.run(cfgDatabase, design, device, cfgExtractor);
        }


        //======================================================================
        // save configuration mapping database
        std::cout << WRITING_DATABASE_MSG;
        std::ofstream dbFileStream(dbFileName.c_str(), std::ios::binary);
        writeBinary(cfgDatabase, dbFileStream);


        //======================================================================
        // write out stats
        std::cout << WRITING_STATS_MSG;
        {
            std::ofstream statsFileStream(statsFileName.c_str());
            DeviceCfgDbStats statsPrinter;
            statsPrinter.printStats(cfgDatabase, device, statsFileStream);
        }


        //======================================================================
        // finished
        std::cout << FINISHED_MSG;
    }
    catch (const CommandLineException& e)
    {
        std::cout << ERROR_MSG << e.what() << INFO_MSG;
        return EXIT_FAILURE;
    }
    catch (...)
    {
        std::cout << ERROR_UNKNOWN_MSG;
        return EXIT_FAILURE;
    }
    return EXIT_SUCCESS;
}
Exemple #21
0
void WriteAiVector3D(Bitstream &s, const aiVector3D &v)
{
	s.WriteFloat(v.x);
	s.WriteFloat(v.y);
	s.WriteFloat(v.z);
}
Exemple #22
0
void WriteAiVector3DHalf(Bitstream &s, const aiVector3D &v)
{
	s.WriteHalf(v.x);
	s.WriteHalf(v.y);
	s.WriteHalf(v.z);
}
Exemple #23
0
void TsPacket::skip_to_end(Bitstream & bitstream)
{
	log4c_category_log(mycat, LOG4C_PRIORITY_TRACE, "skip_to_end %d bytes @ %d offset", ts_packet_size, data_packet_start_byte_offset);
	bitstream.skip_bytes_calibrate(data_packet_start_byte_offset, ts_packet_size);
}