Skip to content

Commit

Permalink
Fix entropy range encoding in octree pointcloud compression
Browse files Browse the repository at this point in the history
Size of frequency table elements was wrongly computed when frequency was a power of 2.
This led to faulty frequency table encoding with 1 missing byte.
During decoding, the frequency was decoded to 0 as 1 byte is missing, leading to
division by 0 and thus error.

The frequencyTableByteSize is now correctly computed.
  • Loading branch information
nicolas-cadart committed Jan 22, 2020
1 parent 7380056 commit 0aaa6ac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion io/include/pcl/compression/impl/entropy_range_coder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ pcl::StaticRangeCoder::encodeIntVectorToStream (std::vector<unsigned int>& input

// calculate amount of bytes per frequency table entry
std::uint8_t frequencyTableByteSize = static_cast<std::uint8_t> (std::ceil (
std::log2 (static_cast<double> (cFreqTable_[static_cast<std::size_t> (frequencyTableSize - 1)])) / 8.0));
std::log2 (static_cast<double> (cFreqTable_[static_cast<std::size_t> (frequencyTableSize - 1)] + 1)) / 8.0));

// write size of frequency table to output stream
outputByteStream_arg.write (reinterpret_cast<const char*> (&frequencyTableSize), sizeof(frequencyTableSize));
Expand Down

0 comments on commit 0aaa6ac

Please sign in to comment.