Commit Graph
15 Commits
Author SHA1 Message Date
leonarski_fandClaude Opus 4.8 ac75177c5a Test: prove Huffman-literals Compressed_Block with Number_of_Sequences=0 is valid
Builds a single Compressed_Block (Huffman-coded Literals_Section, empty
Sequences_Section) and checks: the block type is Compressed, its trailing
Number_of_Sequences byte is 0, and stock ZSTD_decompress reconstructs the
literals exactly. This is the format guarantee from zstd_compression_format.md
("if Number_of_Sequences == 0 ... Block's decompressed content is defined solely
by the Literals Section content"), locked into the test suite.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 14:47:16 +02:00
leonarski_fandClaude Opus 4.8 7e7a73062c Compression: add BSHUF_ZSTD_RLE_HUFF (RLE runs + Huffman literals)
New CompressionAlgorithm that emits a standard Zstandard frame: zero/0xFF runs
become RLE_Blocks (like BSHUF_ZSTD_RLE) and literal regions become
Compressed_Blocks with per-block adaptive Huffman literals and no sequences
(Number_of_Sequences=0). Short runs are absorbed into the literal stream;
incompressible literals fall back to Raw_Blocks so the worst case stays within
ZSTD_compressBound.

The Huffman tree + bitstream are produced by zstd's own HUF_compress{1,4}X_repeat
(the same calls ZSTD_compressLiterals uses); only the frame/block/literals-section
framing is hand-written, with comments citing zstd_compression_format.md so it can
be checked clause by clause. Output decodes with stock ZSTD_decompress, so no
reader changes are needed (decode routes like BSHUF_ZSTD).

On sparse diffraction this gives ~12% smaller files than bitshuffle/LZ4 at about
the same end-to-end speed, sitting between LZ4 and full ZSTD; for maximum ratio
use BSHUF_ZSTD. Robust on any input: tests round-trip pure zeros, Poisson(10),
Mersenne-Twister noise (checked against the size bound), an extreme-sparsity mask,
and a real lyso image through stock ZSTD_decompress.

API: exposed as "bszstd_rlehuf"; regenerate the Python/TS clients (update_version.sh)
to surface the new value there.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 14:41:46 +02:00
leonarski_fandClaude Opus 4.8 02514bb6b7 Compressor: throw on overflow instead of returning a negative size
Compress() and FrameTransformation::CompressImage() returned int64_t with a
negative value meaning "did not fit". That is a footgun: the negative result
silently converts to a huge size_t if a caller forgets to check it. Return
size_t and instead throw a named CompressionBufferTooSmallException (deriving
from JFJochException, Compression category) when the output would not fit the
destination buffer.

The receiver catches it explicitly and drops just that frame, as before; the
offline/GetCompressedImage path uses a worst-case buffer so it never throws.
Add a test that a too-small destination throws and a worst-case buffer does not.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 08:17:21 +02:00
leonarski_fandClaude Opus 4.8 c332e45a54 Compressor: make Compress size-aware, drop frames that don't fit
JFJochBitShuffleCompressor::Compress now takes a dest_size and returns a
negative value when the compressed output would not fit, instead of writing
past the destination buffer. The check is lazy: before each block it verifies
the remaining space still covers that block's worst case (mirrored by the new
MaxCompressedBlockSize helper, consistent with MaxCompressedSize so a dest
sized to MaxCompressedSize never fails). On overflow the dest content is
undefined - no rescue.

The receiver uses this to compress directly into the writer buffer slot and
drop just the oversized frame instead of pre-reserving the full worst-case
image size next to the per-image CBOR metadata.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 20:10:52 +02:00
leonarski_f 040cf08386 v1.0.0-rc.36 2025-05-05 19:32:22 +02:00
leonarski_f 28d224afab version 1.0.0-rc.25 2024-11-22 21:25:20 +01:00
leonarski_f e812918e2e version 1.0.0-rc.13 2024-10-05 13:14:49 +02:00
leonarski_f 91fd44bff7 Improve release/versioning of Jungfraujoch repository 2024-05-15 11:29:01 +02:00
leonarski_f 59aacf516d Updates March 2023 2024-03-14 20:26:03 +01:00
leonarski_f f778a35e6f DiffractionExperiment: Move internal variables to a C++ structure 2023-11-14 13:17:58 +01:00
leonarski_f e85988dfa2 DiffractionExperiment: Clean-up Compression and UnitCell 2023-11-13 17:06:34 +01:00
leonarski_f b2743072e6 DiffractionExperiment: Remove frame summation (summation only on FPGA) 2023-11-06 16:09:08 +01:00
leonarski_f 16bbf54f2a Remove open source license (for now) 2023-09-15 10:47:21 +02:00
leonarski_f 0973f3725d Detector Geometry customization 2023-04-12 19:22:13 +00:00
leonarski_f 1757d42182 Initial commit
Signed-off-by: Filip Leonarski <filip.leonarski@psi.ch>
2023-04-06 11:17:59 +02:00