Skip to content

enum InterPredMode and enum CompInterPredMode: make real enums#927

Open
folkertdev wants to merge 2 commits intomainfrom
folkertdev/inter-pred-mode-enum
Open

enum InterPredMode and enum CompInterPredMode: make real enums#927
folkertdev wants to merge 2 commits intomainfrom
folkertdev/inter-pred-mode-enum

Conversation

@folkertdev
Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread src/levels.rs
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 thread src/levels.rs
Comment on lines +202 to +205
Nearest = 0,
Near = 1,
Global = 2,
New = 3,
Copy link
Copy Markdown
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 thread src/levels.rs
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
Copy Markdown
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