Skip to content

Instantly share code, notes, and snippets.

View sverbach's full-sized avatar
🤠

sverbach sverbach

🤠
View GitHub Profile
@crearo
crearo / ColorConversions.java
Last active February 4, 2024 17:06
YUV420P to RGBA8888 color conversion - with explanation as to why you may fail trying this in java
/**
* It took me a whole 6 hours to finally get the color conversion right.
* I have a fairly good understanding of the various color formats (YUV420P, SP, 422, etc etc),
* and how to access individual Y, U, and V components.
* I however struggled because of a very simple yet hair-pulling gotcha.
* All primitives in Java are signed! If you come from a Python-like world where 0xFF prints 255,
* you see yourself struggle just the same. I am however embarrassed at spending 6 hours on this.
*
* @author rish
*/