This project implements Exponential Golomb Coding in C# with zero allocation
There are two ways to use this project:
- Copy the project source file: Include the source code directly in your project.
- Use NuGet: Install the package using the following command:
dotnet add package ExponentialGolombCoding
Encode a single unsigned integer with order 0:
var bytes = new ExpGolombCoder().Encode(863, 0);
Encode multiple unsigned integer with order 0:
var bytes = new ExpGolombCoder().Encode([22,33,77,88], 0);
Encode multiple unsigned integer with order 0 to Base64:
var str = new ExpGolombCoder().EncodeToBase64([22,33,77,88], 0);
The ExpGolombCoder
class also provides equivalent methods for decoding the encoded data.
All methods in ExpGolombCoder
avoid allocation during processing, except for the final result (bytes or string). This improves performance for memory-intensive tasks.
The project includes the ExpGolombCoderCore
class. This class offers methods for encoding and decoding with absolutely no allocation. Refer to the unit tests for usage examples.
Note: Using ExpGolombCoderCore
might require more complex code compared to the simpler ExpGolombCoder
class.