Skip to content

API: CPP API: Flexible Rate Decoding

Samuel Li edited this page Dec 14, 2023 · 1 revision

As documented on the utility page, SPERR supports "Flexible Rate Decoding" where a prefix of a bitstream remains valid to reconstruct the 3D volume but with less precision. The action of truncation is best to be performed by the class SPERR3D_Stream_Tools, because it handles well with multiple chunks. I.e., it takes a portion of the first chunk, and then a portion of the second chunk, and so on, and then concatenate all of the portions together with a proper header.

Class SPERR3D_Stream_Tools has two methods performing this task:

auto progressive_read(std::string filename, unsigned pct) const -> std::vector<uint8_t>;  // Version 1
auto progressive_truncate(const void* stream, size_t stream_len, unsigned pct) const -> std::vector<uint8_t>;  // Version 2

The former is intended to be used to read a file from disk, where this method locates and reads necessary portions of the file only. The latter is intended to be used to truncate a bitstream that already exists in the memory.