Comments (6)
The simplest way is to add from_u16
method which would create Frame from u16 planes.
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 from_u8
).
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?
from y4m.
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.
from y4m.
for a use case that should be fairly common
Seems like it, accepting u16 planes might give better user experience in real world use-cases.
Would you like to implement from_u16
for Frame
?
from y4m.
Sure, I will give it a try.
The conversion could look like this:
planes.iter().map(|&plane| plane.iter()
.flat_map(|&plane_value| vec![(plane_value >> 8) as u8, plane_value as u8])
.collect()).collect();
Which results in a Vec<Vec<u8>>
. Afterwards slicing the inner vectors for 3 planes should be enough, but due to the Frame structure containing a reference to frame data rather than owning that data, I have not been able to figure out a clean way to persist this processed data, as the borrow dies as the constructor returns. Changing plane data to a vector type would allow it to own the data, but I'm not sure that this is desirable.
from y4m.
(Haven't seen github notifications for last post editings.)
I think we should unsafely represent u16 as u8 with from_raw_parts
.
from y4m.
OK, I was trying to avoid unsafe code but that should work, I will try it soon.
from y4m.
Related Issues (11)
- Support 10-bit y4m. HOT 2
- Parametrize Frame and Encoder/Decoder with Colorspace
- Have the encoder/decoder own the Writer/Reader HOT 2
- Move to image-rs HOT 7
- No protection against OoM on large width or height HOT 6
- c6c592838222d749d3ca3aa00c58bdc78dada465 was an API break on a patch version bump HOT 1
- from_u16 is not correct on big endian platforms
- next release HOT 3
- compile with rav1e HOT 1
- Documentation dispute: C420 really same as C420mpeg2? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from y4m.