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

Make apply_ssim_boost a const fn #3352

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

FreezyLemon
Copy link
Contributor

@FreezyLemon FreezyLemon commented Feb 20, 2024

The ILog trait was introduced in v_frame before {integer}::ilog became stable. const fn doesn't do much here, but it's simple to do, so one might as well.

Note that the functions are similar but not equal in behavior:
ILog::ilog is effectively

if x == 0 {
  0
} else {
  x.ilog2() + 1
}

x.ilog2() will panic if x == 0, but that is already assumed to not be the case here (and it looks like the check for zero is optimized away in all callsites).

shssoichiro
shssoichiro previously approved these changes Feb 20, 2024
Copy link

codecov bot commented Feb 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (3c3a26f) 88.52% compared to head (c7cef88) 88.54%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3352      +/-   ##
==========================================
+ Coverage   88.52%   88.54%   +0.01%     
==========================================
  Files          89       89              
  Lines       28323    28355      +32     
==========================================
+ Hits        25074    25107      +33     
+ Misses       3249     3248       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shssoichiro shssoichiro dismissed their stale review February 20, 2024 02:01

Hold on, I'm just double checking something here

const INSHIFT: u8 = 16;
const OUTSHIFT: u8 = 14;

let k = ((ILog::ilog(x) - 1) >> 1) as i16;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just making sure, is the removal of the - 1 intentional here? My guess is yes given the docs in v_frame: floor(log2(self)) + 1, or 0 if self == 0, but want to be certain this is bit-identical to the prior output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's intentional and I did make sure they're equivalent for x != 0: https://rust.godbolt.org/z/Gh5TxbEYK

@shssoichiro shssoichiro merged commit 0504761 into xiph:master Feb 20, 2024
25 checks passed
@FreezyLemon FreezyLemon deleted the constify-apply-ssim-boost branch February 20, 2024 07:02
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