HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fastCompression.h
Go to the documentation of this file.
1 //`
2 // Copyright 2017 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 
7 #ifndef PXR_BASE_TF_FAST_COMPRESSION_H
8 #define PXR_BASE_TF_FAST_COMPRESSION_H
9 
10 /// \file tf/fastCompression.h
11 /// Simple fast data compression/decompression routines.
12 
13 #include "pxr/pxr.h"
14 
15 #include "pxr/base/tf/api.h"
16 
17 #include <cstddef>
18 
20 
22 {
23 public:
24  /// Return the largest input buffer size that can be compressed with these
25  /// functions. Guaranteed to be at least 200 GB.
26  TF_API static size_t
28 
29  /// Return the largest possible compressed size for the given \p inputSize
30  /// in the worst case (input is not compressible). This is larger than
31  /// \p inputSize. If inputSize is larger than GetMaxInputSize(), return 0.
32  TF_API static size_t
33  GetCompressedBufferSize(size_t inputSize);
34 
35  /// Compress \p inputSize bytes in \p input and store the result in
36  /// \p compressed. The \p compressed buffer must point to at least
37  /// GetCompressedBufferSize(uncompressedSize) bytes. Return the number of
38  /// bytes written to the \p compressed buffer. Issue a runtime error and
39  /// return ~0 in case of an error.
40  TF_API static size_t
41  CompressToBuffer(char const *input, char *compressed, size_t inputSize);
42 
43  /// Decompress \p compressedSize bytes in \p compressed and store the
44  /// result in \p output. No more than \p maxOutputSize bytes will be
45  /// written to \p output.
46  TF_API static size_t
47  DecompressFromBuffer(char const *compressed, char *output,
48  size_t compressedSize, size_t maxOutputSize);
49 };
50 
51 
53 
54 #endif // PXR_BASE_TF_FAST_COMPRESSION_H
55 
56 
#define TF_API
Definition: api.h:23
static TF_API size_t CompressToBuffer(char const *input, char *compressed, size_t inputSize)
static TF_API size_t DecompressFromBuffer(char const *compressed, char *output, size_t compressedSize, size_t maxOutputSize)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
static TF_API size_t GetCompressedBufferSize(size_t inputSize)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
static TF_API size_t GetMaxInputSize()