Video Compression
Summary
The IPBridge prototype uses a single-level Haar wavelet compressor as a proof-of-concept codec for validating the video pipeline. It is not standards-compliant JPEG XS (ISO/IEC 21122). The compressor processes YCbCr 4:2:2 pixel pairs in streaming fashion, producing either lossy (1.33:1 ratio at QUANT_SHIFT>=1) or lossless (0.8:1 expansion at QUANT_SHIFT=0) output. Phase 2 will replace this with a compliant JPEG XS encoder.
Current State
- RTL module
wavelet_compressis complete with parameterized quantization shift. - Top-level integration uses QUANT_SHIFT=2, PIXEL_WIDTH=16.
- Testbench validates both lossy (QUANT_SHIFT=2) and lossless (QUANT_SHIFT=0) modes with round-trip decompression.
- Lossy mode achieves PSNR > 30 dB on test patterns. Constant pixel blocks reconstruct exactly.
- Lossless mode produces pixel-perfect round-trip (PSNR = infinity).
- Compression ratio for lossy mode: exactly 1.33:1 (3 bytes per pixel pair from 4 bytes input).
Key Files
- rtl/wavelet_compress.sv - Haar wavelet compressor with parameterized quantization
- sim/tb_wavelet_compress.sv - Testbench: lossy/lossless round-trip, PSNR, compression ratio
- docs/phase1-test-plan.md - TC-7: Compression Ratio test case
Technical Details
Haar Lifting Transform
For each pixel pair (A=even, B=odd), each 16-bit pixel is split into hi/lo 8-bit components:
H = A - B (signed, range [-255, 255])
L = B + floor(H/2) (unsigned, range [0, 255])
Output Format
Lossy (QUANT_SHIFT >= 1): 3 bytes per pair
[L_hi, L_lo, packed_H]packed_H = {H_hi_quant[3:0], H_lo_quant[3:0]}- H is quantized by arithmetic right-shift of (QUANT_SHIFT + 1) bits
Lossless (QUANT_SHIFT = 0): 5 bytes per pair
[L_hi, L_lo, H_hi_upper, H_lo_upper, H_lsb_packed]- Full 9-bit H coefficients preserved (slight expansion: 0.8:1)
Decompression (Inverse Lifting)
Lossy: H_recon = sign_extend_4bit(nybble) <<< (QUANT_SHIFT+1). Then B = L - floor(H_recon/2), A = H_recon + B, clamp to [0,255].
Lossless: H = {H_upper, H_lsb} (signed 9-bit). Then B = L - floor(H/2), A = H + B. Exact reconstruction.
Pipeline Architecture
- Pair collection: Alternates even/odd pixels on
pair_phasetoggle. - Haar computation: Combinational lifting + quantization, registered in pipeline stage 1.
- Byte serializer: Emits 3 or 5 bytes per pair with a one-deep pending buffer to handle throughput mismatch.
Latency: 4 clock cycles from second pixel of pair to first output byte.
Parameters
| Parameter | Default | Description |
|---|---|---|
| QUANT_SHIFT | 2 | Right-shift for H coefficient quantization (0=lossless) |
| PIXEL_WIDTH | 16 | Input pixel width (YCbCr 4:2:2 = 16 bits) |
Sources
- rtl/wavelet_compress.sv
- sim/tb_wavelet_compress.sv
- docs/phase1-test-plan.md