Skip to content

v0.4.0

Latest

Choose a tag to compare

@peterc peterc released this 28 Sep 17:07
· 3 commits to main since this release

PureJPEG 0.4.0 reduces encoding and decoding time and memory use, and adds experimental compatibility with Spinel.

Performance

Measured on Apple M5 with Ruby 4.0.2 + YJIT, using warmed median-of-nine timings:

Operation Before 0.4.0 Less time
Encode (color, q85) 154 ms 131 ms 15%
Encode (q95, optimized Huffman) 267 ms 235 ms 12%
Baseline decode 133 ms 112 ms 16%
Progressive decode 173 ms 139 ms 20%
Photograph decode (peppers.jpg) 56 ms 41 ms 28%

The first four workloads use the bundled 1024x1024 images. Baseline decode allocations fell from 76,994 to 114, and encoding array storage allocated fell from 29.4 MB to 12.6 MB. Results depend on the image and runtime.

Changes include simpler Huffman loops and category calculations, scan-reference lookup outside inner loops, combined quantization/zigzag passes, two-row chroma processing, and fewer temporary pixels during RawSource construction.

Encoded bytes and decoded pixels matched the previous implementation across 432 encoding cases and 10 JPEG decodes. Existing public APIs remain unchanged.

Experimental Spinel compatibility

  • Compatibility adjustments and benchmarks for Spinel revision 7f08abd9.
  • A rake test:spinel proof-of-concept runner that compiles selected existing tests and compares their output with CRuby.
  • Seven of eight selected RawSource tests pass on the documented Spinel revision. The remaining test fails because respond_to? is unavailable on its pixel struct; the runner preserves that failure.

See Spinel testing notes for setup and limitations. The README includes performance comparisons for CRuby, TruffleRuby, JRuby, and Spinel.

Tests

Added regression coverage for quantization rounding, progressive coefficient offsets, and chroma downsampling edges.

Full changelog

Release validation: all 103 tests pass on CRuby 4.0.2, CRuby 3.3.11, and TruffleRuby 34.0.1. The 0.4.0 gem builds successfully.