46 #ifndef OPENVDB_TOOLS_STREAM_COMPRESSION_HAS_BEEN_INCLUDED 47 #define OPENVDB_TOOLS_STREAM_COMPRESSION_HAS_BEEN_INCLUDED 50 #include <tbb/spin_mutex.h> 55 class TestStreamCompression;
60 namespace compression {
88 const size_t bufferBytes,
const char* uncompressedBuffer,
const size_t uncompressedBytes);
99 const size_t uncompressedBytes,
size_t& compressedBytes,
const bool resize =
true);
115 const size_t bufferBytes,
const char* compressedBuffer);
125 const size_t expectedBytes,
const bool resize =
true);
145 std::streamoff filepos;
146 long compressedBytes;
147 long uncompressedBytes;
151 using Ptr = std::shared_ptr<Page>;
160 long uncompressedBytes()
const;
164 const char* buffer(
const int index)
const;
167 void readHeader(std::istream&);
171 void readBuffers(std::istream&,
bool delayed);
174 bool isOutOfCore()
const;
178 void copy(
const std::unique_ptr<
char[]>& temp,
int pageSize);
181 void decompress(
const std::unique_ptr<
char[]>& temp);
186 std::unique_ptr<Info> mInfo = std::unique_ptr<Info>(
new Info);
187 std::unique_ptr<char[]> mData;
188 tbb::spin_mutex mMutex;
197 #if OPENVDB_ABI_VERSION_NUMBER >= 6 198 using Ptr = std::unique_ptr<PageHandle>;
200 using Ptr = std::shared_ptr<PageHandle>;
213 int size()
const {
return mSize; }
217 std::unique_ptr<char[]> read();
223 friend class ::TestStreamCompression;
238 using Ptr = std::shared_ptr<PagedInputStream>;
258 void read(
PageHandle::Ptr& pageHandle, std::streamsize n,
bool delayed =
true);
262 int mUncompressedBytes = 0;
263 std::istream* mIs =
nullptr;
265 bool mSizeOnly =
false;
275 using Ptr = std::shared_ptr<PagedOutputStream>;
298 void compressAndWrite(
const char* buffer,
size_t size);
301 void resize(
size_t size);
303 std::unique_ptr<char[]> mData = std::unique_ptr<char[]>(
new char[
PageSize]);
304 std::unique_ptr<char[]> mCompressedData =
nullptr;
307 std::ostream* mOs =
nullptr;
308 bool mSizeOnly =
false;
316 #endif // OPENVDB_TOOLS_STREAM_COMPRESSION_HAS_BEEN_INCLUDED std::shared_ptr< Page > Ptr
Definition: StreamCompression.h:151
std::istream & getInputStream()
Definition: StreamCompression.h:249
void setInputStream(std::istream &is)
Definition: StreamCompression.h:250
SharedPtr< MappedFile > Ptr
Definition: io.h:152
OPENVDB_API bool bloscCanCompress()
Returns true if compression is available.
A Paging wrapper to std::istream that is responsible for reading from a given input stream and creati...
Definition: StreamCompression.h:235
void setSizeOnly(bool sizeOnly)
Size-only mode tags the stream as only writing size data.
Definition: StreamCompression.h:282
bool sizeOnly() const
Definition: StreamCompression.h:283
void setSizeOnly(bool sizeOnly)
Size-only mode tags the stream as only reading size data.
Definition: StreamCompression.h:245
A Paging wrapper to std::ostream that is responsible for writing from a given output stream at interv...
Definition: StreamCompression.h:272
std::unique_ptr< PageHandle > Ptr
Definition: StreamCompression.h:198
static const int BLOSC_MINIMUM_BYTES
Definition: StreamCompression.h:65
Stores a variable-size, compressed, delayed-load Page of data that is loaded into memory when accesse...
Definition: StreamCompression.h:138
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
Ptr copy()
Return a copy of this PageHandle.
Definition: StreamCompression.h:220
static const int BLOSC_PAD_BYTES
Definition: StreamCompression.h:69
A PageHandle holds a unique ptr to a Page and a specific stream pointer to a point within the decompr...
Definition: StreamCompression.h:194
Definition: Exceptions.h:40
std::ostream & getOutputStream()
Set and get the output stream.
Definition: StreamCompression.h:286
OPENVDB_API size_t bloscUncompressedSize(const char *buffer)
Retrieves the uncompressed size of buffer when uncompressed.
void setOutputStream(std::ostream &os)
Definition: StreamCompression.h:287
std::shared_ptr< T > SharedPtr
Definition: Types.h:139
bool sizeOnly() const
Definition: StreamCompression.h:246
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.
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
OPENVDB_API size_t bloscCompressedSize(const char *buffer, const size_t uncompressedBytes)
Convenience wrapper to retrieve the compressed size of buffer when compressed.
int size() const
Return the size of the buffer.
Definition: StreamCompression.h:213
static const int PageSize
Definition: StreamCompression.h:132
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.
std::shared_ptr< PagedInputStream > Ptr
Definition: StreamCompression.h:238
std::shared_ptr< PagedOutputStream > Ptr
Definition: StreamCompression.h:275