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

Make plane generic over pixel component type #1002

Merged
merged 1 commit into from
Feb 21, 2019
Merged

Conversation

rom1v
Copy link
Collaborator

@rom1v rom1v commented Feb 15, 2019

In order to support both u8 and u16 for plane components, make the Plane structure generic over the component type. As a consequence, many other structures and functions also become generic.

Some functions are not u8-compatible yet, although they have been make generic over the component type to make the compilation work. They assert that the size of the generic parameter is 16 bits wide.

For this reason, the root context structure is unconditionally created as Context<u16> for now.

@rom1v rom1v force-pushed the generic branch 2 times, most recently from cf4d348 to c501fc7 Compare February 15, 2019 15:32
@coveralls
Copy link
Collaborator

coveralls commented Feb 15, 2019

Coverage Status

Coverage decreased (-0.3%) to 79.812% when pulling 32c19dd on rom1v:generic into baec5d3 on xiph:master.

@tdaede
Copy link
Collaborator

tdaede commented Feb 16, 2019

FrameInvariants becoming generic really adds a lot of noise :/ this is because of the reference frame structure correct?

@rom1v
Copy link
Collaborator Author

rom1v commented Feb 16, 2019

this is because of the reference frame structure correct?

Yes, just because of its field:

pub rec_buffer: ReferenceFramesSet<T>,

@tdaede
Copy link
Collaborator

tdaede commented Feb 16, 2019

Do you think it would make sense to do some dynamic dispatch over that field? Or does that make it even more complicated?

@rom1v
Copy link
Collaborator Author

rom1v commented Feb 16, 2019

Do you think it would make sense to do some dynamic dispatch over that field?

That would mean erasing its concrete type behind a trait:

pub trait RFS {}

impl<T: Pixel> RFS for ReferenceFramesSet<T> {}

pub struct FrameInvariants {
    // …
    pub rec_buffer: Box<dyn RFS>,
    // …
}

But then, from a FrameInvariants, we could not expose the Frames of the rec_buffer (because its concrete type would be lost), so every action on the ReferenceFrameSet<T> would need to be implemented through methods on the RFS trait.

It would be impractical IMO.

In fact, ReferenceFrameSet needs to updated with a FrameState<T>, which is not possible if concrete type of the ReferenceFrameSet is not known (unless we also erase the FrameState parameter…).

@tdaede
Copy link
Collaborator

tdaede commented Feb 16, 2019

I see. I guess we could also split out ReferenceFrameSet to be its own parameter. But that doesn't make many things better.

@tdaede tdaede requested a review from lu-zero February 16, 2019 01:27
@tdaede
Copy link
Collaborator

tdaede commented Feb 16, 2019

lu_zero can you check how the api.rs changes interact with crav1e?

@lu-zero
Copy link
Collaborator

lu-zero commented Feb 16, 2019

They would break everything, but I can fix after it lands.

@lu-zero
Copy link
Collaborator

lu-zero commented Feb 16, 2019

I need to check what works better compared to dyn dispatch, but we could also at a certain point of the chain use just a proxy like this

enum Something {
   Something16(SomethingInner<u16>),
   Something8(SomethingInner<u8>
}

With From and Deref made to unwrap to the actual type.

@rom1v rom1v force-pushed the generic branch 3 times, most recently from e10d054 to 8c386e3 Compare February 19, 2019 20:05
Copy link
Collaborator

@tdaede tdaede left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still wish we could have FI not be per-depth but I think this is currently the best option.

In order to support both u8 and u16 for plane components, make the Plane
structure generic over the component type. As a consequence, many other
structures and functions also become generic.

Some functions are not u8-compatible yet, although they have been make
generic over the component type to make the compilation work. They
assert that the size of the generic parameter is 16 bits wide.

For this reason, the root context structure is unconditionally created
as Context<u16> for now.
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.

4 participants