#3466: test Sharpen's render at Amount 4000

At the top of the new range the CPU render stays linear in Amount
(colour moves Amount / 50 of its difference from the blur) and finite on
32 bpc over-range input, and the GPU matches the CPU at 8 and 32 bpc.
This commit is contained in:
arnav-hiwarkar
2026-11-17 16:05:37 +05:30
parent 1dc70637bd
commit 1a4697de31
2 changed files with 32 additions and 0 deletions
+30
View File
@@ -1049,6 +1049,36 @@ mod tests {
);
}
/// #3466: at the new top of the range the render stays linear in Amount and finite on 32 bpc
/// over-range input: colour moves away from the blur by Amount / 50 of the difference
/// (2000 → 4000 doubles it), never below 0, and alpha is untouched.
#[test]
fn sharpen_is_linear_and_finite_up_to_amount_4000() {
let mut img = edge();
for y in 0..8 {
for x in 0..20 {
img.set(x, y, [1000.0, 1000.0, 1000.0, 1.0]);
}
}
let sharpen = |a: f64| run_fx("ec.blur.sharpen", &[("amount", num(a))], img.clone(), 0.0, EffectEnv::default()).img;
let (half, top) = (sharpen(2000.0), sharpen(4000.0));
for y in 0..8 {
for x in 0..40 {
let (i, h, t) = (img.get(x, y), half.get(x, y), top.get(x, y));
assert_eq!(t[3], i[3], "alpha at {x}");
for c in 0..3 {
assert!(t[c].is_finite() && t[c] >= 0.0, "({x}, {y}): {t:?}");
if t[c] > 0.0 && h[c] > 0.0 {
let (dh, dt) = (h[c] - i[c], t[c] - i[c]);
assert!((dt - 2.0 * dh).abs() <= 1e-3 * dt.abs().max(1.0), "({x}, {y}): {dh} {dt}");
}
}
}
}
// The bright side of the edge moves 80 × its difference from the blur: far past 10 × the input.
assert!(top.get(19, 4)[0] > 1000.0 * 10.0, "{:?}", top.get(19, 4));
}
#[test]
fn fractional_box_blur_radius_is_continuous() {
let row = |v| blurred_row("ec.blur.fastbox", "radius", v);
+2
View File
@@ -75,6 +75,8 @@ fn edge_preserving_blurs() {
fn sharpen_and_unsharp_mask() {
effect_case("ec.blur.sharpen", &[("amount", n(60.0))]);
effect_case("ec.blur.sharpen", &[("amount", n(250.0))]);
// #3466: the top of After Effects' range (80 × the difference from the blur).
effect_case("ec.blur.sharpen", &[("amount", n(4000.0))]);
effect_case("ec.blur.unsharp", &[("amount", n(120.0)), ("radius", n(4.0))]);
effect_case("ec.blur.unsharp", &[("amount", n(80.0)), ("radius", n(2.5)), ("threshold", n(12.0))]);
}