| 356 | } |
| 357 | |
| 358 | void CompressedVectorReaderImpl::feedPacketToDecoders( uint64_t currentPacketLogicalOffset ) |
| 359 | { |
| 360 | // Get packet at currentPacketLogicalOffset into memory. |
| 361 | auto dpkt = dataPacket( currentPacketLogicalOffset ); |
| 362 | |
| 363 | // Double check that have a data packet. Should have already determined this. |
| 364 | if ( dpkt->header.packetType != DATA_PACKET ) |
| 365 | { |
| 366 | throw E57_EXCEPTION2( ErrorInternal, "packetType=" + toString( dpkt->header.packetType ) ); |
| 367 | } |
| 368 | |
| 369 | // Read earliest packet into cache and send data to decoders with unblocked output |
| 370 | |
| 371 | bool anyChannelHasExhaustedPacket = false; |
| 372 | uint64_t nextPacketLogicalOffset = UINT64_MAX; |
| 373 | |
| 374 | // Feed bytestreams to channels with unblocked output that are reading from this packet |
| 375 | for ( DecodeChannel &channel : channels_ ) |
| 376 | { |
| 377 | // Skip channels that have already read this packet. |
| 378 | if ( _alreadyReadPacket( channel, currentPacketLogicalOffset ) ) |
| 379 | { |
| 380 | continue; |
| 381 | } |
| 382 | |
| 383 | // Get bytestream buffer for this channel from packet |
| 384 | unsigned int bsbLength = 0; |
| 385 | const char *bsbStart = dpkt->getBytestream( channel.bytestreamNumber, bsbLength ); |
| 386 | |
| 387 | // Double check we are not off end of buffer |
| 388 | if ( channel.currentBytestreamBufferIndex > bsbLength ) |
| 389 | { |
| 390 | throw E57_EXCEPTION2( |
| 391 | ErrorInternal, |
| 392 | "currentBytestreamBufferIndex =" + toString( channel.currentBytestreamBufferIndex ) + |
| 393 | " bsbLength=" + toString( bsbLength ) ); |
| 394 | } |
| 395 | |
| 396 | // Calc where we are in the buffer |
| 397 | const char *uneatenStart = &bsbStart[channel.currentBytestreamBufferIndex]; |
| 398 | const size_t uneatenLength = bsbLength - channel.currentBytestreamBufferIndex; |
| 399 | |
| 400 | if ( &uneatenStart[uneatenLength] > &bsbStart[bsbLength] ) |
| 401 | { |
| 402 | throw E57_EXCEPTION2( ErrorInternal, "uneatenLength=" + toString( uneatenLength ) + |
| 403 | " bsbLength=" + toString( bsbLength ) ); |
| 404 | } |
| 405 | |
| 406 | // Feed into decoder |
| 407 | const size_t bytesProcessed = channel.decoder->inputProcess( uneatenStart, uneatenLength ); |
| 408 | |
| 409 | #ifdef E57_VERBOSE |
| 410 | std::cout << " stream[" << channel.bytestreamNumber << "]: feeding decoder " |
| 411 | << uneatenLength << " bytes" << std::endl; |
| 412 | |
| 413 | if ( uneatenLength == 0 ) |
| 414 | { |
| 415 | channel.dump( 8 ); |
nothing calls this directly
no test coverage detected