Skip to content
New issue

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

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

Already on GitHub? # to your account

fn loop_restoration_filter: Take safe lpf arg for Rust fallbacks #1202

Merged
merged 6 commits into from
Jun 14, 2024

Conversation

randomPoison
Copy link
Collaborator

@randomPoison randomPoison commented Jun 13, 2024

Pass the full DisjointMut buffer and an isize offset into the loop_restoration_filter function, then reconstruct the offset in the Rust fallback functions. This makes the Rust fallbacks fully safe.

@randomPoison randomPoison requested a review from kkysen June 13, 2024 21:37
@kkysen kkysen self-assigned this Jun 13, 2024
Copy link
Collaborator

@kkysen kkysen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some little things but generally it LGTM.

@@ -170,10 +174,22 @@ impl loop_restoration_filter::Fn {
let dst_ptr = dst.as_mut_ptr::<BD>().cast();
let dst_stride = dst.stride();
let left = left[..h as usize].as_ptr().cast();
let lpf = lpf.cast();
// NOTE: The calculated pointer may point to before the beginning of
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// NOTE: The calculated pointer may point to before the beginning of
// SAFETY: The calculated pointer may point to before the beginning of

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a safety comment though. None of the operations it's documenting are unsafe, it's just explaining why we need to use wrapping_offset instead of offset.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but it's very safety adjacent, and explains why we aren't doing something unsafe. I think it's better to use SAFETY for searchability, too.

@kkysen kkysen changed the title loop_restoration_filter: Take safe lpf arg for Rust fallbacks fn loop_restoration_filter: Take safe lpf arg for Rust fallbacks Jun 14, 2024
@randomPoison randomPoison merged commit cb1bd86 into main Jun 14, 2024
26 checks passed
@kkysen kkysen deleted the legare/looprestoration/lpf-arg branch June 14, 2024 19:19
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

looprestoration.rs: Unsafe cleanup
2 participants