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

Handling 10bit/12bit/14bit Colors #9

Closed
vchuravy opened this issue Sep 14, 2015 · 3 comments
Closed

Handling 10bit/12bit/14bit Colors #9

vchuravy opened this issue Sep 14, 2015 · 3 comments

Comments

@vchuravy
Copy link

I am currently working with a raw YCbCr 10bit Video format and I would like to use the Colors framework for that.

So the simplest solution is to use 16bit for each channel and just assume that no operations is going to set more than 10bits. Alternatively 10 bit YCbCr can be represented with 32 bit but that doesn't fit that well in the current design of Colors and ColorTypes.

I started experimenting on how an instance of a 10bit format would look like: https://gist.github.com/vchuravy/daf8ff63fb5bd5ac6dea, but I think it would be nice if Colors could handle 10/12/14 bits for Colors

@timholy
Copy link
Member

timholy commented Sep 14, 2015

The groundwork is already present, as FixedPointNumbers already supports both signed and unsigned fixed-point numbers. (It even implements Ufixed10, Ufixed12, Ufixed14.) But I'm guessing you're referring to a packed format? That isn't something we support yet, but we could. There's a precedent in that the AbstractRGB types have red, green, blue accessors and support RGB24/ARGB32, which are bit-packed representations and don't have r, g, b fields. You could study these two types and base your implementation off of them.

ColorTypes strongly shies away from having a split between "integer" color values (0-255) and "floating-point" color values (0-1); instead, use FixedPointNumbers to represent "integers" as the equivalent fractional value.

@timholy
Copy link
Member

timholy commented Sep 14, 2015

Oh, and you definitely don't need that Gray10 type, just use Gray{Ufixed10}.

@vchuravy
Copy link
Author

Oh I haven't seen Ufixed10 That is really neat. That should solve most of my problems.

I don't think Colors etc. needs to support packed formats yet, there are simply to many. Writing an unpacker is fairly straight forward :)

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

No branches or pull requests

2 participants