Pxdct — Discrete Cosine and Sine Transform Factory
Pxdct is a high-performance DCT/DST library for Rust supporting arbitrary transform lengths, not just powers of 2.
Why Pxdct
Most DCT libraries require power-of-2 window sizes. Pxdct efficiently handles any length by automatically selecting the best algorithm:
- Split-radix for power-of-2 sizes
- Mixed-radix decomposition for sizes with small prime factors (3, 5, 7, 11, 13…)
- Prime Factor Algorithm (PFA) for coprime factorizations
- Butterflies for sizes up to 512
Sizes that are products of small primes (2, 3, 5, 7, 11, 13) perform best. Large prime sizes fall back to a general FFT-based path and are still O(n log n) but slower than smooth numbers of similar magnitude.
Hardware acceleration is applied automatically where available (AVX2, NEON).
Hardware acceleration is applied automatically:
- AVX2
- NEON
Supported Transforms
| Transform | Description |
|---|---|
| DCT-I / DST-I | Type 1 |
| DCT-II / DST-II | The classic DCT / DST |
| DCT-III / DST-III | Inverse of type II |
| DCT-IV | Used in MDCT |
| MDCT/IMDCT | Modified cosine transform |
| DCT-VII / DST-VII | Type 7 |
| DCT-VIII / DST-VIII | Type 8 |
Both f32 and f64 precision are supported.
Example
use Pxdct;
use PxdctExecutor;
This project is licensed under either of
at your option.