Skip to content

Add some debug asserts to help with local reasoning#2979

Open
RunDevelopment wants to merge 2 commits into
image-rs:mainfrom
RunDevelopment:claude-more-ls
Open

Add some debug asserts to help with local reasoning#2979
RunDevelopment wants to merge 2 commits into
image-rs:mainfrom
RunDevelopment:claude-more-ls

Conversation

@RunDevelopment
Copy link
Copy Markdown
Member

Addresses L46 and L47 from #2954.

Comment thread src/codecs/avif/yuv.rs

impl YuvIntensityRange {
pub(crate) const fn get_yuv_range(self, depth: u32) -> YuvChromaRange {
debug_assert!(matches!(depth, 8..=16));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We seem to be checking the bit depth in all individual callers:

    assert!(
        (8..=16).contains(&BIT_DEPTH),
        "Invalid bit depth is provided"
    );

With this being an internal but supposedly local reasoning maybe we should use a simple wrapper type for it instead of u32 in this case?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Might be tricky. Before this function, bit depth is passed around with const generics everywhere. So switching to a parameter might make perf worse. I can't test this though, since avif-native doesn't work on my machine (out of the box).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants