-
Notifications
You must be signed in to change notification settings - Fork 18
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
Allow Frame struct initialization with u16 data #13
Comments
The simplest way is to add A bit better method is to implement #11 and accept either u8 or u16 depending on the colorspace. But it would be impossible to create high bitdepth frame from u8 planes then (unless introducing something like Also I'm not entirely sure y4m should deal with concept of pixels. Because u8 vs u16 is about the pixel values, not the data stream. Any frame can be represented as a stream of u8. What do you think? |
Handling pixel values instead of raw data does introduce some additional concerns. We can leave it as is and leave the user with the responsibility of providing the raw data in u8 format. On the other hand, converting from high bit depth u16 data to u8 in safe Rust seems to require a significant amount of boilerplate for a use case that should be fairly common, so there is a clear benefit in handling this conversion as part of y4m. |
Seems like it, accepting u16 planes might give better user experience in real world use-cases. Would you like to implement |
Sure, I will give it a try. The conversion could look like this:
Which results in a |
(Haven't seen github notifications for last post editings.) I think we should unsafely represent u16 as u8 with |
OK, I was trying to avoid unsafe code but that should work, I will try it soon. |
When encoding at high bit depths, unless passing decoded frames right back to the encoder, we currently have to perform
u16
tou8
conversions in order to initialize aFrame
. The two options to do that that I am aware of are an unsafefrom_raw_parts
operation, or iterating over each input pixel to generate a new frame. It would be convenient to have a constructor for high bit depth data that could perform one of these options when fedu16
input. Alternatively, a frame could always maintain au16
buffer and the encoder could write asu8
when outputting in 8-bit.The text was updated successfully, but these errors were encountered: