zoomvtools 2.0.0

Video motion vector analysis utilities in pure Rust
Documentation
# SATD KERNELS KNOWLEDGE BASE

**Generated:** 2026-04-17

## OVERVIEW

Sum of Absolute Transformed Differences kernels. Hadamard-transformed block matching metric.

## STRUCTURE

```
src/satd/
├── rust.rs    # Scalar implementation
├── avx2.rs    # AVX2 SIMD implementation
├── tests.rs   # Test generator macro (get_satd_tests!)
└── satd.rs    # Module root, dispatch
```

## WHERE TO LOOK

| Area          | File       | Notes                                                     |
| ------------- | ---------- | --------------------------------------------------------- |
| Scalar SATD   | `rust.rs`  | Baseline reference with Hadamard transform                |
| AVX2 SATD     | `avx2.rs`  | SIMD-optimized Hadamard + SAD, compiled with `avx2` feature |
| Test coverage | `tests.rs` | `get_satd_tests!` macro generates tests for both backends |
| Dispatch      | `satd.rs`  | `#[cfg]` + cpudetect-backed runtime gate                 |

## CONVENTIONS

- Standard `rust.rs` + `avx2.rs` + `tests.rs` pattern.
- `avx2` feature gates AVX2 backend compilation; `--no-default-features` keeps scalar-only coverage.
- Runtime dispatch uses `cpudetect::x86_64::is_x86_64_v3_compatible()` at the boundary.
- Hadamard transform must produce identical results in scalar and AVX2 paths.
- Test generator `get_satd_tests!($module)` covers both backends.
- Both `u8` and `u16` pixel types tested.
- Used in DCT-based search modes (mode 3, 4) alongside SAD.

## ANTI-PATTERNS

- Diverging Hadamard results between scalar and AVX2 (validated by `verify_asm!`).
- Incorrect transform ordering (rows before columns, or vice versa).
- Missing overflow handling for 16-bit accumulators.