-
Notifications
You must be signed in to change notification settings - Fork 22
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
struct Rav1dIntraPredDspContext
: Fix defaults
#583
Conversation
fa222c0
to
f3feffc
Compare
662f110
to
1d210ad
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.
I think we should do something to not reinit on every frame so we don't deviate from the original code. (github won't let me change my review without a comment, that's all this is)
f3feffc
to
3aa1661
Compare
ca53d47
to
f2c5e8f
Compare
3aa1661
to
348b7db
Compare
f2c5e8f
to
7d0c2ce
Compare
… a `initialized: bool` field (on `struct Rav1dDSPContext`) as they are always `Some` even if `.is_none()` is checked. `.is_none()` appears to be checked so that it can lazily initialize DSPs, relying on things being zero-initialized to begin with. Ideally we should move initialization to DSP allocation so its not lazy, but for now (and the way closest to the C), we can use a single initialized flag instead of `Option`s on everything.
…:cfl_pred` to defaults to avoid unitialized memory, as not all (4/6) elements are initialized.
7d0c2ce
to
4609590
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.
The changes here look fine to me, but make sure you've addressed @rinon's requests before merging.
I just hadn't gotten a chance to look at it, LGTM thanks 👍 |
This replaces the
Option
s on.intra_pred
with aninitialized: bool
field as they are alwaysSome
even if.is_none()
is checked..is_none()
appears to be checked so that it can lazily initialize DSPs, relying on things being zero-initialized to begin with.Ideally we should move initialization to DSP allocation so its not lazy, but for now (and the way closest to the C), we can use a single initialized flag instead of
Option
s on everything.This also default initializes
.cfl_pred
as it otherwise isn't fully initialized and is thus leaving uninitialized memory, which is UB if it is made a reference at any point (which it is). This usesDefaultValue::DEFAULT
for initialization instead ofNone
, though, which moves the check from before the call (.unwrap()
/.expect()
) to inside a call that should never happen (unimplemented!()
). Normally thoseunimplemented!()
s will be dead code eliminated, but here they won't. Thus, it shouldn't add any perf cost and only a small binary size cost.