Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gpuopen-librariesandsdks/brotli_g_sdk
Brotli-G SDK provides an improved lossless compression ratio with GPU decompression support than the standard Brotli compression algorithm maintained by the IETF (also known as RFC7932)
https://github.com/gpuopen-librariesandsdks/brotli_g_sdk
brotli compression gpu web
Last synced: 5 days ago
JSON representation
Brotli-G SDK provides an improved lossless compression ratio with GPU decompression support than the standard Brotli compression algorithm maintained by the IETF (also known as RFC7932)
- Host: GitHub
- URL: https://github.com/gpuopen-librariesandsdks/brotli_g_sdk
- Owner: GPUOpen-LibrariesAndSDKs
- License: mit
- Created: 2022-11-17T17:23:21.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-18T14:23:24.000Z (7 months ago)
- Last Synced: 2024-04-19T15:10:51.851Z (7 months ago)
- Topics: brotli, compression, gpu, web
- Language: C++
- Homepage:
- Size: 16 MB
- Stars: 147
- Watchers: 11
- Forks: 10
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Brotli-G SDK
This project contains the specifications and reference implementations for the Brotli-G compression format:
[Brotli-G Bitstream Spec](docs/Brotli_G_Bitstream_Format.pdf)The use of this technical documentation is goverened by the [License](LICENSE.txt).
# Source
* `src/decoder/BrotliGCompute.hlsl` - start here to read the HLSL source of the GPU decompressor
* `src/decoder/PageDecoder.cpp` - start here to read the source of the CPU decompressor
* `src/BrotligDecoder.cpp` - this contains the code driving the CPU decompressor
* `src/encoder/PageEncoder.cpp` - start here to read the source of the compressor
* `src/BrotligEncoder.cpp` - entry point for the compressor## Getting Started
The repo uses CMake build system. Install CMake >= 3.11 if not installed.
## Building
Run "Build.bat" from a Visual Studio Developer Command Prompt to generate build files. Open the build files in compiler of choice and compile. Outputs are static libraries `build\external\brotli\Release\brotli.lib` and `build\Release\brotlig.lib`.
## Usage
To use in a visual studio project, include `inc` `external` and `external\brotli\c\include` as include directories and link `build\external\brotli\Release\brotli.lib` and `build\Release\brotlig.lib` as external libraries.
Relevant header files:
* `inc/BrotligEncoder.h` - function declarations for Brotli-G compressor
* `inc/BrotligDecoder.h` - function declarations for Brotli-G CPU decompressor
* `inc/BrotliG.h` - Brolti-G API header file for both compressor and CPU decompressor
* `inc/DataStream.h` - data structures for Brotli-G datastreamCode examples:
```
// Compression
void Compress(size_t srcSize, uint8_t* src, size_t& dstSize, uint8_t*& dst, BrotligDataconditionParams dcParams)
{
dstSize = BrotliG::MaxCompressedSize(srcSize);
dst = new uint8_t[dstSize];
size_t actualSize = 0;
BrotliG::Encode(
srcSize, // input size (bytes)
src, // input data
&actualSize, // actual compressed size (bytes)
dst, // compressed output
65536, // page size (bytes)
dcParams, // data pre-conditioning parameters
nullptr // handle to an application defined progress function
);
dstSize = actualSize;
}
```
```
// CPU Decompression
void DecompressCPU(size_t srcSize, uint8_t* src, size_t& dstSize, uint8_t*& dst)
{
dstSize = BrotliG::DecompressedSize(src);
dst = new uint8_t[dstSize];
size_t actualSize = 0;
BrotliG::DecodeCPU(
srcSize, // compressed size (bytes)
src, // compressed data
&actualSize, // decompressed size (bytes)
dst, // decompressed output
nullptr // handle to an application defined progress function
);
dstSize = actualSize;
}
```Example root signature for BrotliGCompute.hlsl:
```
CD3DX12_ROOT_PARAMETER1 rootParameters[RootParametersCount];
rootParameters[RootSRVInput].InitAsShaderResourceView(0); // Compressed data buffer (SRV input)
rootParameters[RootUAVControl].InitAsUnorderedAccessView(0); // Compressed data control buffer (UAV input)
rootParameters[RootUAVOutput].InitAsUnorderedAccessView(1); // Decompressed data buffer (UAV output)
```
## SampleSource code of a sample demostrating the usage of Brotli-G APIs is provided in the `sample` directory.`Build.bat` builds the sample by default.
Sample build output `bin\Release\brotlig.exe`.
Using the sample:
* BrotliG cpu compression: `brotlig.exe `
* BrotliG cpu deccompression: `brotlig.exe .brotlig`
* BrotliG gpu decompression: `brotlig.exe -gpu .brotlig`
* Help: `brotlig.exe`