# TX2-IFF (Involuted Fractal Format)
TX2-IFF is a next-generation image compression codec built on the principles of **Physics-Prime Factorization (PPF)** and **Symplectic Geometry**. It is designed to achieve high compression ratios for complex, high-entropy images by storing the *generators* of the image content rather than the content itself.
## Key Features
* **Symplectic Compression**: Uses symplectic warp fields to model geometric deformations.
* **Physics-Prime Factorization**: Utilizes "360-Prime" quantization tables derived from the factors of 360 ($2^3 \times 3^2 \times 5$).
* **Three-Layer Architecture**:
1. **Wavelet Skeleton**: CDF 5/3 biorthogonal wavelets in YCoCg-R color space (4:2:0 subsampled).
2. **Texture Flesh**: Procedural synthesis for high-entropy regions using PPF noise.
3. **Warp Field**: Sparse symplectic vectors for geometric coherence.
* **Zstd Residuals**: Efficient compression of residual data using Zstd.
* **GPU Acceleration**: WGPU-based decoder for fast reconstruction.
## Installation
Add this to your `Cargo.toml`:
```toml
[dependencies]
tx2-iff = "0.1.0"
```
## Usage
### Encoding
```rust
use tx2_iff::encoder::{Encoder, EncoderConfig};
use image::io::Reader as ImageReader;
fn main() {
let img = ImageReader::open("input.png").unwrap().decode().unwrap();
let rgb = img.to_rgb8();
let config = EncoderConfig::default();
let encoder = Encoder::new(config);
let iff_data = encoder.encode(&rgb, img.width(), img.height()).unwrap();
std::fs::write("output.iff", iff_data).unwrap();
}
```
### Decoding
```rust
use tx2_iff::format::IffImage;
use tx2_iff::decoder::{Decoder, DecoderConfig};
fn main() {
let data = std::fs::read("output.iff").unwrap();
let iff_image = IffImage::from_bytes(&data).unwrap();
let decoder = Decoder::new(DecoderConfig::default());
let rgb_pixels = decoder.decode(&iff_image).unwrap();
// Use rgb_pixels...
}
```
## Viewer
This crate includes a viewer binary that uses `tx2-core` to display `.iff` files.
```bash
cargo run --bin viewer --features gpu -- <path_to_image.iff>
```
## License
MIT