42#ifndef __PCL_IO_RANGECODING__HPP
43#define __PCL_IO_RANGECODING__HPP
45#include <pcl/compression/entropy_range_coder.h>
59 const DWord top =
static_cast<DWord> (1) << 24;
60 const DWord bottom =
static_cast<DWord> (1) << 16;
66 outputCharVector_.clear ();
67 outputCharVector_.reserve (
sizeof(
char) *
input_size);
75 for (
unsigned int i = 0; i < 257; i++)
89 while ((
low ^ (
low + range)) < top || ((range < bottom) && ((range = -
int (
low) & (bottom - 1)), 1)))
91 char out =
static_cast<char> (
low >> 24);
94 outputCharVector_.push_back (out);
98 for (
unsigned int j =
ch + 1; j < 257; j++)
105 for (
unsigned int f = 1; f <= 256; f++)
116 for (
unsigned int i = 0; i < 4; i++)
118 char out =
static_cast<char> (
low >> 24);
119 outputCharVector_.push_back (out);
126 return (
static_cast<unsigned long> (outputCharVector_.size ()));
137 const DWord top =
static_cast<DWord> (1) << 24;
138 const DWord bottom =
static_cast<DWord> (1) << 16;
152 for (
unsigned int i = 0; i < 4; i++)
161 for (
unsigned int i = 0; i <= 256; i++)
168 std::uint8_t
sSize = 256 / 2;
191 while ((
low ^ (
low + range)) < top || ((range < bottom) && ((range = -
int (
low) & (bottom - 1)), 1)))
202 for (
unsigned int j =
symbol + 1; j < 257; j++)
209 for (
unsigned int f = 1; f <= 256; f++)
227 const std::uint64_t top =
static_cast<std::uint64_t
> (1) << 56;
228 const std::uint64_t bottom =
static_cast<std::uint64_t
> (1) << 48;
229 const std::uint64_t
maxRange =
static_cast<std::uint64_t
> (1) << 48;
234 outputCharVector_.clear ();
235 outputCharVector_.reserve ((
sizeof(
char) *
input_size * 2));
242 cFreqTable_[0] = cFreqTable_[1] = 0;
276 cFreqTable_[f] = cFreqTable_[f - 1] + cFreqTable_[f];
277 if (cFreqTable_[f] <= cFreqTable_[f - 1])
278 cFreqTable_[f] = cFreqTable_[f - 1] + 1;
284 for (std::size_t f = 1; f < cFreqTable_.size (); f++)
288 if (cFreqTable_[f] <= cFreqTable_[f - 1])
289 cFreqTable_[f] = cFreqTable_[f - 1] + 1;
295 std::log2 (
static_cast<double> (cFreqTable_[
static_cast<std::size_t
> (
frequencyTableSize - 1)] + 1)) / 8.0));
311 std::uint64_t
low = 0;
312 std::uint64_t range =
static_cast<std::uint64_t
> (-1);
326 while ((
low ^ (
low + range)) < top || ((range < bottom) && ((range = -
low & (bottom - 1)), 1)))
328 char out =
static_cast<char> (
low >> 56);
331 outputCharVector_.push_back (out);
337 for (
unsigned int i = 0; i < 8; i++)
339 char out =
static_cast<char> (
low >> 56);
340 outputCharVector_.push_back (out);
347 streamByteCount +=
static_cast<unsigned long> (outputCharVector_.size ());
358 const std::uint64_t top =
static_cast<std::uint64_t
> (1) << 56;
359 const std::uint64_t bottom =
static_cast<std::uint64_t
> (1) << 48;
390 std::uint64_t
code = 0;
391 std::uint64_t
low = 0;
392 std::uint64_t range =
static_cast<std::uint64_t
> (-1);
395 for (
unsigned int i = 0; i < 8; i++)
413 if (cFreqTable_[
static_cast<std::size_t
> (
symbol +
sSize)] <= count)
424 low += cFreqTable_[
static_cast<std::size_t
> (
symbol)] * range;
425 range *= cFreqTable_[
static_cast<std::size_t
> (
symbol + 1)] - cFreqTable_[
static_cast<std::size_t
> (
symbol)];
428 while ((
low ^ (
low + range)) < top || ((range < bottom) && ((range = -
low & (bottom - 1)), 1)))
450 const DWord top =
static_cast<DWord> (1) << 24;
451 const DWord bottom =
static_cast<DWord> (1) << 16;
460 outputCharVector_.clear ();
461 outputCharVector_.reserve (
sizeof(
char) *
input_size);
476 for (
int f = 1; f <= 256; f++)
486 for (
int f = 1; f <= 256; f++)
502 range =
static_cast<DWord> (-1);
515 while ((
low ^ (
low + range)) < top || ((range < bottom) && ((range = -
int (
low) & (bottom - 1)), 1)))
517 char out =
static_cast<char> (
low >> 24);
520 outputCharVector_.push_back (out);
526 for (
int i = 0; i < 4; i++)
528 char out =
static_cast<char> (
low >> 24);
529 outputCharVector_.push_back (out);
536 streamByteCount +=
static_cast<unsigned long> (outputCharVector_.size ());
549 const DWord top =
static_cast<DWord> (1) << 24;
550 const DWord bottom =
static_cast<DWord> (1) << 16;
572 range =
static_cast<DWord> (-1);
575 for (
unsigned int i = 0; i < 4; i++)
588 std::uint8_t
sSize = 256 / 2;
608 while ((
low ^ (
low + range)) < top || ((range < bottom) && ((range = -
int (
low) & (bottom - 1)), 1)))
unsigned long decodeStreamToCharVector(std::istream &inputByteStream_arg, std::vector< char > &outputByteVector_arg)
Decode char stream to output vector.
unsigned long encodeCharVectorToStream(const std::vector< char > &inputByteVector_arg, std::ostream &outputByteStream_arg)
Encode char vector to output stream.
Iterator class for point clouds with or without given indices.
std::size_t size() const
Size of the range the iterator is going through.
unsigned long decodeStreamToIntVector(std::istream &inputByteStream_arg, std::vector< unsigned int > &outputIntVector_arg)
Decode stream to output integer vector.
unsigned long encodeCharVectorToStream(const std::vector< char > &inputByteVector_arg, std::ostream &outputByteStream_arg)
Encode char vector to output stream.
unsigned long decodeStreamToCharVector(std::istream &inputByteStream_arg, std::vector< char > &outputByteVector_arg)
Decode char stream to output vector.
unsigned long encodeIntVectorToStream(std::vector< unsigned int > &inputIntVector_arg, std::ostream &outputByterStream_arg)
Encode integer vector to output stream.