-
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
enum InterPredMode
and enum CompInterPredMode
: make real enums
#927
base: main
Are you sure you want to change the base?
Conversation
impl From<InterPredMode> for CompInterPredMode { | ||
fn from(value: InterPredMode) -> Self { | ||
match value { | ||
InterPredMode::Nearest => CompInterPredMode::NearestNearest, | ||
InterPredMode::Near => CompInterPredMode::NearNear, | ||
InterPredMode::Global => CompInterPredMode::NearestNew, | ||
InterPredMode::New => CompInterPredMode::NewNearest, | ||
} | ||
} | ||
} |
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.
this conversion happens in practice, though I don't really understand why it makes sense. Maybe the CompInterPredMode
field is just implicitly a InterPredMode
in certain circumstances? or there is something more subtle going on.
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.
but e.g. Global
mapping to NearestNew
is weird when GlobalGlobal
exists.
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.
That is very weird. I have no idea why that's done. It looks like a correct translation of the C, though. @fbossen, have any idea?
Maybe the same fields are being used for the two enum
s, but never at the same time? I'm curious if the tests would still pass if we changed the conversion to what would be expected.
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.
there is this one expression that mixes the two types
(b.inter_mode() == if is_comp { GLOBALMV_GLOBALMV } else { GLOBALMV }) as c_int;
so, I guess, if is_comp
is true then CompInterPredMode
is used, and otherwise just InterPredMode
. That at least intuitively makes sense here, and also seems to be true in this file.
Not sure what to do with that though, is_comp
is a runtime value so it's hard encode that into the type. Some enum { Comp(_), NotComp(_) }
enum also doesn't seem great (but would provide some extra type safety).
Nearest = 0, | ||
Near = 1, | ||
Global = 2, | ||
New = 3, |
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've kept the number here for now because the ordering is important for the mapping to CompInterPredMode
impl From<InterPredMode> for CompInterPredMode { | ||
fn from(value: InterPredMode) -> Self { | ||
match value { | ||
InterPredMode::Nearest => CompInterPredMode::NearestNearest, | ||
InterPredMode::Near => CompInterPredMode::NearNear, | ||
InterPredMode::Global => CompInterPredMode::NearestNew, | ||
InterPredMode::New => CompInterPredMode::NewNearest, | ||
} | ||
} | ||
} |
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.
That is very weird. I have no idea why that's done. It looks like a correct translation of the C, though. @fbossen, have any idea?
Maybe the same fields are being used for the two enum
s, but never at the same time? I'm curious if the tests would still pass if we changed the conversion to what would be expected.
32f97e8
to
f10d302
Compare
5711bfe
to
9743090
Compare
No description provided.