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

enum InterPredMode and enum CompInterPredMode: make real enums #927

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

folkertdev
Copy link
Collaborator

No description provided.

Comment on lines +220 to +229
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,
}
}
}
Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

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 enums, 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.

Copy link
Collaborator Author

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).

Comment on lines +202 to +205
Nearest = 0,
Near = 1,
Global = 2,
New = 3,
Copy link
Collaborator Author

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

@kkysen kkysen self-requested a review March 27, 2024 18:25
Comment on lines +220 to +229
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,
}
}
}
Copy link
Collaborator

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 enums, 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.

@folkertdev folkertdev force-pushed the folkertdev/drl-proximity-enum branch from 32f97e8 to f10d302 Compare March 29, 2024 21:43
Base automatically changed from folkertdev/drl-proximity-enum to main March 31, 2024 04:11
@folkertdev folkertdev force-pushed the folkertdev/inter-pred-mode-enum branch from 5711bfe to 9743090 Compare March 31, 2024 12:40
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