diff --git a/crates/jxl-frame/src/filter.rs b/crates/jxl-frame/src/filter.rs index c55613ac..39f48f28 100644 --- a/crates/jxl-frame/src/filter.rs +++ b/crates/jxl-frame/src/filter.rs @@ -30,9 +30,14 @@ impl Bundle for Gabor { let mut weights = [[0.0f32; 2]; 3]; for chan_weight in &mut weights { - for weight in chan_weight { + for weight in &mut *chan_weight { *weight = bitstream.read_f16_as_f32()?; } + if f32::abs(1.0 + (chan_weight[0] + chan_weight[1]) * 4.0) < f32::EPSILON { + return Err(jxl_bitstream::Error::ValidationFailed( + "Gaborish weights lead to near 0 unnormalized kernel" + ).into()); + } } Ok(Self::Enabled(weights)) }