Skip to content

v0.5.0 — PGS encoding and round-trip

Choose a tag to compare

@matthane matthane released this 05 Apr 01:23
· 9 commits to master since this release

Highlights

PGS encoding and round-trip support

libpgs is no longer extract-only. This release adds a complete encoding path so you can read, modify, and write PGS data:

  • DisplaySetBuilder — chainable builder for constructing display sets from structured payloads. Handles RLE encoding and ODS fragmentation automatically.
  • Payload serialization — PcsData, WdsData, PdsData, and OdsData all gain to_bytes() methods. PgsSegment gains from_pcs/wds/pds/ods factories and in-place set_*_payload mutators.
  • RLE encoder — encode_rle(pixels, width, height) complements the existing decoder, enabling full bitmap round-trips.
  • ObjectBitmap type — represents a complete object bitmap (id, dimensions, pixel buffer) for encoding into ODS segments.

encode CLI command

The new libpgs encode -o <output.sup> subcommand reads NDJSON from stdin (in the same format that libpgs stream produces) and writes a .sup file. This closes the round-trip loop for external scripts in any language:

libpgs stream input.mkv | your-script.py | libpgs encode -o output.sup

Multi-track input is automatically split into <stem>_track<id>.sup files. See docs/NDJSON.md for the full protocol reference.

Bug fixes

  • Cue-path block timestamps were off by the block's cluster-relative offset. When extracting PGS from MKV files via the cue fast path (the default for any MKV with a Cues index), read_block_at_position was computing cue_time + block.relative_timestamp, but per the Matroska spec CueTime is already the absolute timestamp of the block referenced by CueRelativePosition. This caused every extracted display set to have an incorrect PTS, shifted by an amount equal to the block's cluster-relative offset (ranging from 0 to several seconds per block). .sup files extracted with v0.4.0 and earlier from cue-indexed MKVs are affected and should be re-extracted with v0.5.0 — output is now byte-for-byte identical to mkvextract.

Documentation

  • STREAMING.md renamed to docs/NDJSON.md and expanded with encode protocol details.
  • README updated with encoding and round-trip examples.