Repository navigation
rust: Add CEA-608 roll-up emitter spike (experimental) - #741
chriscoveries wants to merge 4 commits into
Conversation
Add an obs-captions crate that schedules parity-correct RU2/RU3 cc_data pairs at 30 and 60 fps, with decode-back coverage for pacing and wrapping. This is an isolated emitter spike; it does not connect the pairs to OBS caption output or implement the wider CEA-608 feature set.
Ten regression tests for the roll-up scheduler: a rejected word must leave the timestamp, queue and cursor unchanged; invalid and very large timestamps must fail without partial output; and the last representable 30 and 60 fps frame slots must be usable without the cursor wrapping.
word() advanced the accepted timestamp before validating the word's characters, so a rejected word could make the next valid word fail as non-monotonic. Stage each word and commit its pairs, cursor and timestamp together only after it schedules successfully. Check the frame conversion before narrowing to u32 and use a u64 internal cursor, so a word that would cross the representable frame limit fails as FrameIndexOverflow without emitting part of itself.
|
Review from the maintainer side. I read the body, the comments, the diff at CI. 13 pass, 7 skipped, 0 failing, and the branch merges cleanly (no rebase needed). Code (read, not run). The scheduling logic reads correctly to me: parity, the basic-NA table, double-sent control codes, 32-column wrapping with a carriage return, chunking of long words, and the 30/60 fps cadence. Gaps.
Verdict: (c) needs a maintainer decision. The code is a sound spike, but the real question is direction: whether obs-rust wants a new Rust caption encoder next to the vendored libcaption path, which you also ask in #753. That is not something I should decide in a PR comment, so I am taking it to the repo owner and will post the answer here and on #753. It stays a draft for now; until then the useful, safe work is item 2 and the doc fixes in item 3. |
|
Decision: yes we want this. You are gated and may proceed as designed. 🫡 |
|
Coordinator check-in, @chriscoveries: there's been no activity here since the maintainer's review about 9 days ago. Are you still working on this? If you've moved on, say "handed off to the coordinator" and I'll keep the mechanical work (rebases, list conflicts, formatting) moving. Anything in the review that needs a design change stays with you. |
The docs cited spikes/2026-10-12/rollup, which is not in this repo, and Cargo.toml advertised CEA-708 although only 608 is implemented. Point the docs at the original C spike without the broken path and describe the crate as CEA-608.
|
Coordinator tick: the maintainer approved this on 2026-10-17 and there has been no activity for 11 days, so I took over the mechanical part of the review's gap 3 (doc fixes) and pushed What changed:
Gap 2 (the libcaption differential tier via |
|
Status from the coordinator, @chriscoveries — the branch is red for one reason, and it is not the docs fixup I pushed on 2026-10-28 ( Both jobs run the same inventory check ( and What that means in practice: the crate's three targets are not in I am not doing that one myself — which category owns caption tests is a structure decision in your spike, not a mechanical fixup, and you are the author. If you would rather hand the mechanical part over, say Two standing things, unchanged from my 2026-10-27 note on #743/#742: this is still a draft, and the question there — are you finishing the CEA-608 roll-up, or should I report the spike to the maintainer as dormant — is still open. |
|
Closing. Per #2414, captions go out of tree as a plugin, so this in-core emitter isn't needed. Sorry for leaving it silent for two weeks; life got in the way. Thanks for the doc fixup. |
GOOD MORNING OBSRUSTEES! 👋 Hi @zackees, hi everyone! We're still recovering on CI, but we're back in the game a little. @rdoupe, judging by how fast your fixes land, your CI must be the size of a small moon. 🌕
Real output: the crate's emitted byte pairs written to an SCC file, then decoded by FFmpeg's
eia_608decoder and rendered over a black frame. In the third frame the first line has rolled off the top of the three-row window. This is not a screenshot of OBS.Problem
OBS sends CEA-608 captions today through vendored libcaption, in C. A live-caption source (for example, on-device speech recognition) needs a small, testable piece that turns words into correctly paced 608 roll-up byte pairs. That piece doesn't exist in Rust.
What this PR adds
A new standalone crate,
rust/obs-captions, with a CEA-608 roll-up pair scheduler:FrameIndexOverflowinstead of wrapping the frame counter.Evidence
Local runs on an Apple Silicon Mac at this PR's head (
9a812e8e1):soldr cargo test -p obs-captions --locked, in debug and in release: 21 tests pass. 11 are decode-back tests: a test-side decoder reads the emitted pairs back and checks text, parity, pacing, wrapping and errors, and one compares golden pairs with libcaption's encodings. The other 10 are the new rejection and frame-limit tests.62b17af5b, before the fix), 8 of the 10 new tests fail in both debug and release. One example: rejectingA*Bused to advance the timestamp, so the next valid word failed as non-monotonic. The other 2 are guard tests that pass either way.cargo clippy --all-targets -D warningsandcargo fmt --check: clean.eia_608decoder and rendered with libass.Not done (why this is a draft)
Compatibility & risk
RollupErrorgained aFrameIndexOverflowvariant. Nothing outside the crate matches on it yet.Cargo.lockgains oneobs-captionsentry.Status
Draft. Opened so upstream PR CI can run it, and for direction. Updated with the atomic-rejection fix and its tests. If you'd like this kept, the next step is a small C ABI and one call site that feeds it caption text.
Thank you to the obs-rust maintainers and contributors for building this project in the open. In the American spirit of free expression and individual independence, and with the principle of judging contributions on their merit alone, this PR is a small piece of what independent people can build when they come together.