Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jxl-frame: Check gabor weights #42

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crates/jxl-frame/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ impl<Ctx> Bundle<Ctx> 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))
}
Expand Down