19 #ifndef OPENVDB_TOOLS_STREAM_COMPRESSION_HAS_BEEN_INCLUDED 20 #define OPENVDB_TOOLS_STREAM_COMPRESSION_HAS_BEEN_INCLUDED 23 #include <tbb/spin_mutex.h> 28 class TestStreamCompression;
33 namespace compression {
61 const size_t bufferBytes,
const char* uncompressedBuffer,
const size_t uncompressedBytes);
72 const size_t uncompressedBytes,
size_t& compressedBytes,
const bool resize =
true);
88 const size_t bufferBytes,
const char* compressedBuffer);
98 const size_t expectedBytes,
const bool resize =
true);
116 #ifdef OPENVDB_USE_DELAYED_LOADING 117 io::MappedFile::Ptr mappedFile;
120 std::streamoff filepos;
121 long compressedBytes;
122 long uncompressedBytes;
126 using Ptr = std::shared_ptr<Page>;
135 long uncompressedBytes()
const;
139 const char* buffer(
const int index)
const;
142 void readHeader(std::istream&);
146 void readBuffers(std::istream&,
bool delayed);
149 bool isOutOfCore()
const;
153 void copy(
const std::unique_ptr<
char[]>& temp,
int pageSize);
156 void decompress(
const std::unique_ptr<
char[]>& temp);
161 std::unique_ptr<Info> mInfo = std::unique_ptr<Info>(
new Info);
162 std::unique_ptr<char[]> mData;
163 tbb::spin_mutex mMutex;
172 using Ptr = std::unique_ptr<PageHandle>;
184 int size()
const {
return mSize; }
188 std::unique_ptr<char[]>
read();
194 friend class ::TestStreamCompression;
209 using Ptr = std::shared_ptr<PagedInputStream>;
233 int mUncompressedBytes = 0;
234 std::istream* mIs =
nullptr;
236 bool mSizeOnly =
false;
246 using Ptr = std::shared_ptr<PagedOutputStream>;
269 void compressAndWrite(
const char* buffer,
size_t size);
272 void resize(
size_t size);
274 std::unique_ptr<char[]> mData = std::unique_ptr<char[]>(
new char[
PageSize]);
275 std::unique_ptr<char[]> mCompressedData =
nullptr;
278 std::ostream* mOs =
nullptr;
279 bool mSizeOnly =
false;
287 #endif // OPENVDB_TOOLS_STREAM_COMPRESSION_HAS_BEEN_INCLUDED
void setInputStream(std::istream &is)
Definition: StreamCompression.h:221
Stores a variable-size, compressed, delayed-load Page of data that is loaded into memory when accesse...
Definition: StreamCompression.h:111
OPENVDB_API std::unique_ptr< char[]> bloscCompress(const char *buffer, const size_t uncompressedBytes, size_t &compressedBytes, const bool resize=true)
Compress and return the heap-allocated compressed buffer.
static fileSize_t write(std::ostream &os, const GridHandle< BufferT > &handle, Codec codec, uint32_t n)
std::shared_ptr< T > SharedPtr
Definition: Types.h:114
std::unique_ptr< PageHandle > Ptr
Definition: StreamCompression.h:172
A Paging wrapper to std::ostream that is responsible for writing from a given output stream at interv...
Definition: StreamCompression.h:243
bool sizeOnly() const
Definition: StreamCompression.h:254
std::ostream & getOutputStream()
Set and get the output stream.
Definition: StreamCompression.h:257
static const int BLOSC_MINIMUM_BYTES
Definition: StreamCompression.h:38
std::shared_ptr< PagedOutputStream > Ptr
Definition: StreamCompression.h:246
Definition: Exceptions.h:13
OPENVDB_API bool bloscCanCompress()
Returns true if compression is available.
std::shared_ptr< PagedInputStream > Ptr
Definition: StreamCompression.h:209
OPENVDB_API size_t bloscCompressedSize(const char *buffer, const size_t uncompressedBytes)
Convenience wrapper to retrieve the compressed size of buffer when compressed.
static const int BLOSC_PAD_BYTES
Definition: StreamCompression.h:42
void setSizeOnly(bool sizeOnly)
Size-only mode tags the stream as only reading size data.
Definition: StreamCompression.h:216
static void read(std::istream &is, BufferT &buffer, Codec codec)
A PageHandle holds a unique ptr to a Page and a specific stream pointer to a point within the decompr...
Definition: StreamCompression.h:169
static const int PageSize
Definition: StreamCompression.h:105
OPENVDB_API std::unique_ptr< char[]> bloscDecompress(const char *buffer, const size_t expectedBytes, const bool resize=true)
Decompress and return the the heap-allocated uncompressed buffer.
void setOutputStream(std::ostream &os)
Definition: StreamCompression.h:258
A Paging wrapper to std::istream that is responsible for reading from a given input stream and creati...
Definition: StreamCompression.h:206
void setSizeOnly(bool sizeOnly)
Size-only mode tags the stream as only writing size data.
Definition: StreamCompression.h:253
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
Ptr copy()
Return a copy of this PageHandle.
Definition: StreamCompression.h:191
OPENVDB_API size_t bloscUncompressedSize(const char *buffer)
Retrieves the uncompressed size of buffer when uncompressed.
bool sizeOnly() const
Definition: StreamCompression.h:217
std::shared_ptr< Page > Ptr
Definition: StreamCompression.h:126
std::istream & getInputStream()
Definition: StreamCompression.h:220
int size() const
Return the size of the buffer.
Definition: StreamCompression.h:184
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:212