libCZI
Reading and Writing CZI documents made easy
|
#include <libCZI_compress.h>
Static Public Member Functions | |
static size_t | CalculateMaxCompressedSizeZStd0 (std::uint32_t sourceWidth, std::uint32_t sourceHeight, libCZI::PixelType sourcePixeltype) |
static bool | CompressZStd0 (std::uint32_t sourceWidth, std::uint32_t sourceHeight, std::uint32_t sourceStride, libCZI::PixelType sourcePixeltype, const void *source, const std::function< void *(size_t)> &allocateTempBuffer, const std::function< void(void *)> &freeTempBuffer, void *destination, size_t &sizeDestination, const ICompressParameters *parameters) |
static std::shared_ptr< IMemoryBlock > | CompressZStd0Alloc (std::uint32_t sourceWidth, std::uint32_t sourceHeight, std::uint32_t sourceStride, libCZI::PixelType sourcePixeltype, const void *source, const std::function< void *(size_t)> &allocateTempBuffer, const std::function< void(void *)> &freeTempBuffer, const ICompressParameters *parameters) |
static bool | CompressZStd0 (std::uint32_t sourceWidth, std::uint32_t sourceHeight, std::uint32_t sourceStride, libCZI::PixelType sourcePixeltype, const void *source, void *destination, size_t &sizeDestination, const ICompressParameters *parameters) |
static std::shared_ptr< IMemoryBlock > | CompressZStd0Alloc (std::uint32_t sourceWidth, std::uint32_t sourceHeight, std::uint32_t sourceStride, libCZI::PixelType sourcePixeltype, const void *source, const ICompressParameters *parameters) |
static size_t | CalculateMaxCompressedSizeZStd1 (std::uint32_t sourceWidth, std::uint32_t sourceHeight, libCZI::PixelType sourcePixeltype) |
static bool | CompressZStd1 (std::uint32_t sourceWidth, std::uint32_t sourceHeight, std::uint32_t sourceStride, libCZI::PixelType sourcePixeltype, const void *source, const std::function< void *(size_t)> &allocateTempBuffer, const std::function< void(void *)> &freeTempBuffer, void *destination, size_t &sizeDestination, const ICompressParameters *parameters) |
static std::shared_ptr< IMemoryBlock > | CompressZStd1Alloc (std::uint32_t sourceWidth, std::uint32_t sourceHeight, std::uint32_t sourceStride, libCZI::PixelType sourcePixeltype, const void *source, const std::function< void *(size_t)> &allocateTempBuffer, const std::function< void(void *)> &freeTempBuffer, const ICompressParameters *parameters) |
static bool | CompressZStd1 (std::uint32_t sourceWidth, std::uint32_t sourceHeight, std::uint32_t sourceStride, libCZI::PixelType sourcePixeltype, const void *source, void *destination, size_t &sizeDestination, const ICompressParameters *parameters) |
static std::shared_ptr< IMemoryBlock > | CompressZStd1Alloc (std::uint32_t sourceWidth, std::uint32_t sourceHeight, std::uint32_t sourceStride, libCZI::PixelType sourcePixeltype, const void *source, const ICompressParameters *parameters) |
The functions found here deal with zstd-compression (the compression-part in particular). Those functions are rather low-level, and the common theme is - given a source bitmap, create a blob (containing the compressed bitmap data) which is suitable to be placed in a subblock's data. Several overloads are provided, for performance critical scenarios we provide functions which write directly into caller-provided memory, and there are versions which use caller-provided functions for internal allocations. The latter may be beneficial in high-performance scenarios where pre-allocation and buffer-reuse can be leveraged in order to avoid repeated heap-allocations.
|
static |
Calculates the maximum size which might be required (for the output buffer) when calling into "CompressZStd0". The guarantee here is : if calling into "CompressZStd0" with an output buffer of the size as determined here, the call will NEVER fail (for insufficient output buffer size). Note that this upper limit may be larger than the actual needed size by a huge factor (10 times or more), and it is of the order of the input size.
sourceWidth | The width of the bitmap in pixels. |
sourceHeight | The height of the bitmap in pixels. |
sourcePixeltype | The pixeltype of the bitmap. |
|
static |
Calculates the maximum size which might be required (for the output buffer) when calling into "CompressZStd0". The guarantee here is : if calling into "CompressZStd0" with a output buffer of the size as determined here, the call will NEVER fail (for insufficient output buffer size). Note that this upper limit may be larger than the actual needed size by a huge factor (10 times or more), and it is of the order of the input size.
sourceWidth | The width of the bitmap in pixels. |
sourceHeight | The height of the bitmap in pixels. |
sourcePixeltype | The pixeltype of the bitmap. |
|
static |
Compress the specified bitmap in "zstd0"-format. This method will compress the specified source-bitmap according to the "ZEN-zstd0-scheme" to a caller supplied block of memory. If successful, the used size of the memory block is returned, and the data is suitable to be put into a subblock. Details of the operation are:
sourceWidth | Width of the source bitmap in pixels. | |
sourceHeight | Height of the source bitmap in pixels. | |
sourceStride | The stride of the source bitmap in bytes. | |
sourcePixeltype | The pixeltype of the source bitmap. | |
source | Pointer to the source bitmap. | |
allocateTempBuffer | This functor is called when it is necessary to allocate a temporary buffer. The argument specifies the size in bytes for the buffer. This argument must not be null. If this functor returns null, then this method exception is left with an exception(of type runtime_error). | |
freeTempBuffer | This functor is called when the temporary buffer is to be released. It is guaranteed that this free-functor is called for every temp-buffer-allocation before this method returns. This argument must not be null. | |
[in,out] | destination | The pointer to the output buffer. |
[in,out] | sizeDestination | On input, this gives the size of the destination buffer in bytes. On return of this method (and provided the return value is 'true'), this gives the actual used size (which is always less or equal to the value on input). |
parameters | Property bag containing parameters controlling the operation. This argument can be null, in which case default parameters are used. |
|
static |
Compress the specified bitmap in "zstd0"-format. This method will compress the specified source-bitmap according to the "ZEN-zstd0-scheme" to a caller supplied block of memory. If successful, the used size of the memory block is returned, and the data is suitable to be put into a subblock. Details of the operation are:
sourceWidth | Width of the source bitmap in pixels. | |
sourceHeight | Height of the source bitmap in pixels. | |
sourceStride | The stride of the source bitmap in bytes. | |
sourcePixeltype | The pixeltype of the source bitmap. | |
source | Pointer to the source bitmap. | |
[in,out] | destination | The pointer to the output buffer. |
[in,out] | sizeDestination | On input, this gives the size of the destination buffer in bytes. On return of this method (and provided the return value is 'true'), this gives the actual used size (which is always less or equal to the value on input). |
parameters | Property bag containing parameters controlling the operation. This argument can be null, in which case default parameters are used. |
|
static |
Compress the specified bitmap in "zstd0"-format. This method will compress the specified source-bitmap according to the "ZEN-zstd0-scheme" to a caller supplied block of memory. If successful, the used size of the memory block is returned, and the data is suitable to be put into a subblock. Details of the operation are:
sourceWidth | Width of the source bitmap in pixels. |
sourceHeight | Height of the source bitmap in pixels. |
sourceStride | The stride of the source bitmap in bytes. |
sourcePixeltype | The pixeltype of the source bitmap. |
source | Pointer to the source bitmap. |
parameters | Property bag containing parameters controlling the operation. This argument can be null, in which case default parameters are used. |
|
static |
Compress the specified bitmap in "zstd0"-format. This method will compress the specified source-bitmap according to the "ZEN-zstd0-scheme" to newly allocated memory, and return a blob of memory containing the data suitable to be put into a subblock. Details of the operation are:
sourceWidth | Width of the source bitmap in pixels. |
sourceHeight | Height of the source bitmap in pixels. |
sourceStride | The stride of the source bitmap in bytes. |
sourcePixeltype | The pixeltype of the source bitmap. |
source | Pointer to the source bitmap. |
allocateTempBuffer | This functor is called when it is necessary to allocate a temporary buffer. The argument specifies the size in bytes for the buffer. This argument must not be null. If this functor returns null, then this method exception is left with an exception(of type runtime_error). |
freeTempBuffer | This functor is called when the temporary buffer is to be released. It is guaranteed that this free-functor is called for every temp-buffer-allocation before this method returns. This argument must not be null. |
parameters | Property bag containing parameters controlling the operation. This argument can be null, in which case default parameters are used. |
|
static |
Compress the specified bitmap in "zstd1"-format. This method will compress the specified source-bitmap according to the "ZEN-zstd1-scheme" to a caller supplied block of memory. If successful, the used size of the memory block is returned, and the data is suitable to be put into a subblock. Details of the operation are:
sourceWidth | Width of the source bitmap in pixels. | |
sourceHeight | Height of the source bitmap in pixels. | |
sourceStride | The stride of the source bitmap in bytes. | |
sourcePixeltype | The pixeltype of the source bitmap. | |
source | Pointer to the source bitmap. | |
allocateTempBuffer | This functor is called when it is necessary to allocate a temporary buffer. The argument specifies the size in bytes for the buffer. This argument must not be null. If this functor returns null, then this method exception is left with an exception (of type runtime_error). | |
freeTempBuffer | This functor is called when the temporary buffer is to be released. It is guaranteed that this free-functor is called for every temp-buffer-allocation before this method returns. This argument must not be null. | |
[in,out] | destination | The pointer to the output buffer. |
[in,out] | sizeDestination | On input, this gives the size of the destination buffer in bytes. On return of this method (and provided the return value is 'true'), this gives the actual used size (which is always less or equal to the value on input). |
parameters | Property bag containing parameters controlling the operation. This argument can be null, in which case default parameters are used. |
|
static |
Compress the specified bitmap in "zstd1"-format. This method will compress the specified source-bitmap according to the "ZEN-zstd1-scheme" to a caller supplied block of memory. If successful, the used size of the memory block is returned, and the data is suitable to be put into a subblock. Details of the operation are:
sourceWidth | Width of the source bitmap in pixels. | |
sourceHeight | Height of the source bitmap in pixels. | |
sourceStride | The stride of the source bitmap in bytes. | |
sourcePixeltype | The pixeltype of the source bitmap. | |
source | Pointer to the source bitmap. | |
[in,out] | destination | The pointer to the output buffer. |
[in,out] | sizeDestination | On input, this gives the size of the destination buffer in bytes. On return of this method (and provided the return value is 'true'), this gives the actual used size (which is always less or equal to the value on input). |
parameters | Property bag containing parameters controlling the operation. This argument can be null, in which case default parameters are used. |
|
static |
Compress the specified bitmap in "zstd1"-format. This method will compress the specified source-bitmap according to the "ZEN-zstd1-scheme" to newly allocated memory, and return a blob of memory containing the data suitable to be put into a subblock. Details of the operation are: Details of the operation are:
sourceWidth | Width of the source bitmap in pixels. |
sourceHeight | Height of the source bitmap in pixels. |
sourceStride | The stride of the source bitmap in bytes. |
sourcePixeltype | The pixel type of the source bitmap. |
source | Pointer to the source bitmap. |
parameters | Property bag containing parameters controlling the operation. This argument can be null, in which case default parameters are used. |
|
static |
Compress the specified bitmap in "zstd1"-format. This method will compress the specified source-bitmap according to the "ZEN-zstd1-scheme" to newly allocated memory, and return a blob of memory containing the data suitable to be put into a subblock. Details of the operation are: Details of the operation are:
sourceWidth | Width of the source bitmap in pixels. |
sourceHeight | Height of the source bitmap in pixels. |
sourceStride | The stride of the source bitmap in bytes. |
sourcePixeltype | The pixeltype of the source bitmap. |
source | Pointer to the source bitmap. |
allocateTempBuffer | This functor is called when it is necessary to allocate a temporary buffer. The argument specifies the size in bytes for the buffer. This argument must not be null. If this functor returns null, then this method exception is left with an exception (of type runtime_error). |
freeTempBuffer | This functor is called when the temporary buffer is to be released. It is guaranteed that this free-functor is called for every temp-buffer-allocation before this method returns. This argument must not be null. |
parameters | Property bag containing parameters controlling the operation. This argument can be null, in which case default parameters are used. |