diff --git a/crates/engine/src/assrender.rs b/crates/engine/src/assrender.rs new file mode 100644 index 0000000..65806a8 --- /dev/null +++ b/crates/engine/src/assrender.rs @@ -0,0 +1,1067 @@ +//! Advanced SubStation Alpha drawn as libass draws it: each event in its style's +//! face, scaled from `PlayRes` to the frame, with its outline, shadow, blur and +//! fade, composed onto the picture. An event's coverage is rasterised once and +//! kept while the frame size holds, so a fade is a blend, not a rasterisation. + +use std::collections::HashMap; +use std::path::Path; + +use ab_glyph::{Font, FontRef, GlyphId, OutlineCurve, point}; +use ab_glyph_rasterizer::Rasterizer; +use ec_subs::{Segment, SubtitleStyle}; + +use crate::colorspace::is_sd; +use crate::text::{self, mix, yuv}; + +const ITALIC_SHEAR: f32 = 0.2; +const DEFAULT_EVENT_FORMAT: &str = "Layer,Start,End,Style,Name,MarginL,MarginR,MarginV,Effect,Text"; + +/// One event on screen: its index in the script and its span on the timeline, in microseconds. +#[derive(Clone, Copy, Debug)] +pub struct Shown { + /// The event's index in the script, in file order. + pub event: usize, + /// When the event starts on the timeline. + pub start_us: i64, + /// When the event ends on the timeline. + pub end_us: i64, +} + +/// An ASS script ready to draw: its PlayRes, styles and events, and the coverage of the events drawn. +pub struct Captions { + play: (f32, f32), + scaled: bool, + wrap: u8, + styles: Vec