mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-12 08:52:32 +00:00
Carved from FilmCraft's filmcraft-captions (crates/captions at 4bec22bd): the file readers and writers, CEA-608/708 coding, format detection and the cue document. Rendering and the mapping onto FilmCraft's caption tracks stay there. - time: the crate has its own exact Tick (1/254016000000 s) and rational FrameRate, the subset of filmcraft-time the formats use. - TTML is read through craft-xml instead of roxmltree: no entity expansion, nesting bounded by the reader (128 levels, as before). - parse refuses input over 64 MiB and keeps at most 1,000,000 cues. - MCC and EBU STL name the caller's program (WriteOptions::program). - plain_text (inline tag stripping) moves with the SCC/MCC writers that need it.
19 lines
657 B
Rust
19 lines
657 B
Rust
//! TTML / DFXP export must not overflow for cue times near `i64::MAX` (e.g. from an MCC with a
|
|
//! huge timecode).
|
|
|
|
use craft_captions::Tick;
|
|
use craft_captions::{Cue, Document, Format, WriteOptions, write};
|
|
|
|
fn doc(end: Tick) -> Document {
|
|
Document { cues: vec![Cue { start: Tick(0), end, text: "x".into(), ..Cue::default() }], ..Document::default() }
|
|
}
|
|
|
|
#[test]
|
|
fn ttml_and_dfxp_write_survive_tick_max() {
|
|
for format in [Format::Ttml, Format::Dfxp] {
|
|
let out = write(&doc(Tick(i64::MAX)), format, WriteOptions::default());
|
|
let s = String::from_utf8(out).unwrap();
|
|
assert!(s.contains("end=\""), "{format:?}: {s}");
|
|
}
|
|
}
|