MCPcopy Create free account
hub / github.com/PDAL/PDAL / inputProcessAligned

Method inputProcessAligned

plugins/e57/libE57Format/src/Decoder.cpp:377–468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375}
376
377size_t BitpackFloatDecoder::inputProcessAligned( const char *inbuf, const size_t firstBit,
378 const size_t endBit )
379{
380#ifdef E57_VERBOSE
381 std::cout << "BitpackFloatDecoder::inputProcessAligned() called, inbuf="
382 << reinterpret_cast<const void *>( inbuf ) << " firstBit=" << firstBit
383 << " endBit=" << endBit << std::endl;
384#endif
385 // Read from inbuf, decode, store in destBuffer
386 // Repeat until have filled destBuffer, or completed all records
387
388 size_t n = destBuffer_->capacity() - destBuffer_->nextIndex();
389
390 size_t typeSize = ( precision_ == PrecisionSingle ) ? sizeof( float ) : sizeof( double );
391
392#if VALIDATE_BASIC
393#if 0 // I know no way to do this portably <rs>
394 // Deactivate for now until a better solution is found.
395 // Verify that inbuf is naturally aligned to correct boundary (4 or 8 bytes). Base class should be doing this for us.
396 if (reinterpret_cast<unsigned>(inbuf) % typeSize) {
397 throw E57_EXCEPTION2(ErrorInternal,
398 "inbuf=" + toString(reinterpret_cast<unsigned>(inbuf))
399 + " typeSize=" + toString(typeSize));
400 }
401#endif
402 // Verify first bit is zero
403 if ( firstBit != 0 )
404 {
405 throw E57_EXCEPTION2( ErrorInternal, "firstBit=" + toString( firstBit ) );
406 }
407#endif
408
409 // Calc how many whole records worth of data we have in inbuf
410 size_t maxInputRecords = ( endBit - firstBit ) / ( 8 * typeSize );
411
412 // Can't process more records than we have input data for.
413 if ( n > maxInputRecords )
414 {
415 n = maxInputRecords;
416 }
417
418 // Can't process more than defined in input file
419 if ( n > maxRecordCount_ - currentRecordIndex_ )
420 {
421 n = static_cast<unsigned>( maxRecordCount_ - currentRecordIndex_ );
422 }
423
424#ifdef E57_VERBOSE
425 std::cout << " n:" << n << std::endl; //???
426#endif
427
428 if ( precision_ == PrecisionSingle )
429 {
430 // Form the starting address for first data location in inBuffer
431 auto inp = reinterpret_cast<const float *>( inbuf );
432
433 // Copy floats from inbuf to destBuffer_
434 for ( unsigned i = 0; i < n; i++ )

Callers

nothing calls this directly

Calls 8

binaryStringFunction · 0.85
nextIndexMethod · 0.80
setNextFloatMethod · 0.80
setNextDoubleMethod · 0.80
setNextStringMethod · 0.80
setNextInt64Method · 0.80
toStringFunction · 0.70
capacityMethod · 0.45

Tested by

no test coverage detected