forge
Explore
Log in

Don't you dare go Hollow

🐛 ASS \blur is sized as libass sizes it: sigma 0.849·blur in pixels of the video, not scaled from PlayRes; \be adds its box passes

Browse files at this commit

bc736390285bb6800f108fbac776b3414a6504cdAhmet Kaan GümüşParent: af4a6f7
crates/engine/src/assrender.rsmodified+12 -2
@@ -31,6 +31,7 @@ pub struct Shown {
3131 pub struct Captions {
3232 play: (f32, f32),
3333 scaled: bool,
34+ storage_h: f32,
3435 wrap: u8,
3536 styles: Vec<Style>,
3637 events: Vec<Event>,
@@ -82,6 +83,7 @@ impl Captions {
8283 Some(Captions {
8384 play: (res("play_res_x", 384.0), res("play_res_y", 288.0)),
8485 scaled: meta("scaled_border_and_shadow").is_some_and(|v| v.eq_ignore_ascii_case("yes")),
86+ storage_h: 0.0,
8587 wrap: meta("wrap_style").and_then(|v| v.parse().ok()).unwrap_or(0),
8688 styles,
8789 events,
@@ -89,6 +91,12 @@ impl Captions {
8991 })
9092 }
9193
94+ /// Blur is sized in pixels of a `height`-row video, as libass sizes it against its storage size.
95+ pub fn for_video_height(mut self, height: u32) -> Captions {
96+ self.storage_h = height as f32;
97+ self
98+ }
99+
92100 /// Draws the events `shown` lists at `t_us` onto a BGRA canvas of `size` pixels.
93101 pub fn draw_bgra(&mut self, canvas: &mut [u8], size: (u32, u32), shown: &[Shown], t_us: i64) {
94102 let (w, h) = (size.0 as usize, size.1 as usize);
@@ -248,11 +256,13 @@ impl Captions {
248256 let y0 = top;
249257 let y1 = top + block;
250258 let bsc = if self.scaled { sy } else { 1.0 };
259+ let blur_px = if self.storage_h > 0.0 { hf / self.storage_h } else { 1.0 };
260+ let sigma_of = |r: &Run| ((0.849 * r.blur).powi(2) + 0.5 * r.edge_blur).sqrt() * blur_px;
251261 let reach = walk
252262 .runs
253263 .iter()
254264 .map(|r| {
255- let sigma = (r.blur + r.edge_blur) * bsc;
265+ let sigma = sigma_of(r);
256266 r.border.abs() * bsc + r.shadow.abs() * bsc + 3.0 * sigma
257267 })
258268 .fold(0.0, f32::max);
@@ -274,7 +284,7 @@ impl Captions {
274284 let mut fill = coverage(&glyphs, (mw, mh), (ox as f32, oy as f32));
275285 let border = run.border * bsc;
276286 let shadow = (run.shadow * bsc).round() as i32;
277- let sigma = (run.blur + run.edge_blur) * bsc;
287+ let sigma = sigma_of(run);
278288 let mut edge = Vec::new();
279289 if border > 0.0 {
280290 edge = dilate(&fill, mw, mh, border);
crates/engine/src/export.rsmodified+1 -1
@@ -7055,7 +7055,7 @@ pub fn compose_at_with(
70557055 if let Some((pick, style)) = burn {
70567056 let (sources, cues): (Vec<usize>, Vec<Cue>) = burn_cues_indexed(project, pick, meta.frame_rate)?.into_iter().unzip();
70577057 let on = cues_on_screen(&cues, frame, meta.frame_rate);
7058- match native_script(project, pick, &style) {
7058+ match native_script(project, pick, &style).map(|c| c.for_video_height(meta.height)) {
70597059 Some(mut captions) => {
70607060 let shown = native_shown(&cues, &sources, &on);
70617061 let t_us = (f64::from(frame) / meta.frame_rate * 1e6).round() as i64;