CCSDS 121.0-B-3 Lossless Data Compression (Rice/Golomb coding)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

rice: convert libaec interop to trace-based pattern

Replace live C stubs (requiring libaec at test time) with the standard
generate-once-replay-always pattern. The generator compresses test
vectors with libaec and commits the traces; the test decompresses with
ocaml-rice and verifies byte-exact match.

Constant-data vectors are excluded from compress comparison — CCSDS
121.0-B-3 allows implementation-dependent zero-block encodings. Both
produce valid bitstreams; decompress interop is verified for all vectors.

+33 -7
+14 -2
test/interop/libaec/dune
··· 1 1 (test 2 2 (name test) 3 - (libraries rice csvt alcotest) 3 + (libraries rice csvt astring alcotest) 4 4 (deps 5 - (source_tree traces))) 5 + (source_tree traces) 6 + (source_tree scripts))) 7 + 8 + ; Regenerate traces against libaec: dune build @regen-traces 9 + 10 + (rule 11 + (alias regen-traces) 12 + (deps 13 + (source_tree scripts)) 14 + (action 15 + (chdir 16 + scripts 17 + (run bash ./generate.sh))))
+19 -5
test/interop/libaec/test.ml
··· 4 4 Regenerate: dune build @regen-traces 5 5 6 6 Each trace row contains raw samples compressed by libaec. The test 7 - compresses the same input with ocaml-rice and checks byte-exact match, 8 - then decompresses the libaec output with ocaml-rice and checks it 9 - recovers the original samples. *) 7 + decompresses the libaec output with ocaml-rice and checks it recovers the 8 + original samples (the core interop guarantee). For non-constant data it 9 + also verifies byte-exact compression match. 10 + 11 + {b Known implementation differences (libaec 1.1):} 12 + 13 + - Constant-data blocks (all samples identical) produce different but 14 + spec-valid encodings. CCSDS 121.0-B-3 Section 5.1 allows multiple 15 + representations for zero-block coding. Both decode correctly. Compress 16 + tests are skipped for constant vectors. *) 10 17 11 18 let trace path = Filename.concat "traces" path 12 19 ··· 53 60 | Ok rows -> rows 54 61 | Error e -> Alcotest.failf "CSV: %a" Csvt.pp_error e 55 62 63 + let is_constant vec = Astring.String.is_infix ~affix:"constant" vec.name 64 + 56 65 let test_compress vec () = 57 66 let cfg = 58 67 Rice.config ~block_size:vec.block_size ~bits_per_sample:vec.bits_per_sample ··· 84 93 Alcotest.run "rice-interop-libaec" 85 94 [ 86 95 ( "compress", 87 - List.map 88 - (fun v -> Alcotest.test_case v.name `Quick (test_compress v)) 96 + List.filter_map 97 + (fun v -> 98 + (* Skip constant vectors: CCSDS 121.0 zero-block encoding is 99 + implementation-dependent. Both encodings are valid; only 100 + decompress interop matters. *) 101 + if is_constant v then None 102 + else Some (Alcotest.test_case v.name `Quick (test_compress v))) 89 103 vectors ); 90 104 ( "decompress", 91 105 List.map