mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-26 02:59:17 -06:00
LR-IMP-FORMATS: property tests for the CRX decoder through the public decode path
crates/raw/tests/crx_properties.rs drives lightcraft_raw::decode with synthetic CR3 containers built around CRX streams that the test encodes itself: reference entropy coders for the MED, Rice, MELCODE and QP-map layouts, and the exact algebraic inverse of one 5/3 lifting line. The tile-halo coefficients are free parameters of that inverse, so synthesis must reconstruct any encoded plane exactly. Tests only; no decoder change. - Wavelet round trip: random planes decode exactly across odd plane sizes and multi-tile halo configurations (eight geometries, arbitrary halo values). - Quantization: every uniform quant value 4..=44 and every adaptive QP value 131..=168 dequantizes within the 14-bit range. Overshoot is clamped, and an in-range plane lands exactly on level * step, so the step sequence itself is observable. Quant 3 and 45 and QP 130 and 169 are rejected by decode and probe_info alike. Random QP maps, including odd map heights, with random per-band base and gain stay in range. - Lossless samples outside the bit depth are Corrupt errors instead of being clamped; in-range planes decode exactly. - Adversarial entropy payloads planted in well-formed lossless, C-RAW, version 0x200 and QP-map streams either error or decode deterministically and never panic. A QP Rice prefix longer than the 23-zero escape is Corrupt. - Random IAD1 geometry either decodes with the active area inside the sensor and the crop inside the active area, or is rejected. - Decoding gives identical results across repeated and four-way parallel invocations. - Odd QP-map heights decode: the last QP row has no partner and is used alone, and QP values are averaged before the step lookup. Large QP jumps take the escape code. The case budget is proptest's default (256 per property); set PROPTEST_CASES to change it.
This commit is contained in: