-
Notifications
You must be signed in to change notification settings - Fork 246
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
get_log_tx_scale: remove mutable variable #757
Conversation
@ycho for your consideration. There's probably a way of getting rid of the conditionals altogether with some clever log2 + bittwiddling. |
src/quantize.rs
Outdated
if num_pixels > 1024 { shift_bits += 1; }; | ||
|
||
shift_bits | ||
(num_pixels > 256) as i32 + (num_pixels > 1024) as i32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I tried exactly the same code in the beginning, borrowing from libaom, then rustc cannot pass it, since it does not do automatic type conversion (i.e. casting) from boolean to integer. :) Hence the CI raised red flag!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you did casting, "as i32", sorry missed it-- )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When casted, does rustc generate similar code as C? I,e, ture/false --> 1/0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use as
or i32::from()
like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and yes, boolean -> signed maps to 0/1 and not 0/-1 ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok- thanks for confirm!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lu-zero , And thanks for example code for type conversion above!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the type may change i32::from()
is suggested by clippy since would make refactoring easier. I consider that debatable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lu-zero I think using i32::from()
is reasonable.
Do we know why there is red x over above with travis CI...? |
network problems on their side, I restarted it |
7435edf
to
69410dc
Compare
No functional change.
2b6f62d
to
97e2e0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
* get_log_tx_scale: remove mutable variable No functional change. * quantize: add test for get_log_tx_scale()
No functional change.