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

Restructure and slightly refactor code #13

Merged
merged 10 commits into from
Dec 8, 2022

Conversation

FreezyLemon
Copy link
Contributor

I tried "cleaning up" a bit. Mostly by moving code out of lib.rs. It's now just the tests and some re-exporting from the new modules.

List of changes:

  1. Move code for structs into separate files (Rgb, LinearRgb, Xyb, Yuv). Hsl was already in its own file
  2. Fix a lot of non-functional clippy warnings/errors (mostly FullTypeName -> Self where applicable)
  3. rustfmt
  4. Add into_data() function that "consumes" self to return the data Vec<[f32; 3]>. This is A) needed to implement the conversion functions without pub(crate) and B) can also be used by API users, which is a neat solution IMHO
  5. Make the "internal" modules not-pub. The comment states it's helpful for optimization but I don't really think it's necessary anymore with the benches. Let me know if you disagree.

Altogether, this changes the internal structure a bit but doesn't really touch the public API. You can technically access things like yuvxyb::rgb_xyb::linear_rgb_to_xyb at the moment (which would be impossible after this change), but I'd consider those functions to be internal so this is only a "kind of breaking" change IMO.

Copy link
Collaborator

@shssoichiro shssoichiro left a comment

Choose a reason for hiding this comment

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

Looks good for the most part, just a few questions

@@ -1,3 +1,7 @@
#![allow(clippy::cast_possible_wrap)]
#![allow(clippy::cast_precision_loss)]
#![allow(clippy::cast_sign_loss)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do these need to be added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

powf has some code that causes clippy warnings. For example x.to_bits() as i32 can wrap. If you want, i can go further into it, but IMO the warnings indicate problems that either can't happen with our assumptions or don't matter (wrapping doesn't matter because we're just using the value for bitwise operations).

@shssoichiro shssoichiro merged commit 20d68fb into rust-av:main Dec 8, 2022
@FreezyLemon FreezyLemon deleted the reorganize branch December 8, 2022 13:53
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