Created
January 1, 2022 14:03
-
-
Save mebjas/7296c81161386599e4abd946fab3da2d to your computer and use it in GitHub Desktop.
Skeleton code of YUV to RGB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct RGBA_8888 { | |
uint8_t r; | |
uint8_t g; | |
uint8_t b; | |
uint8_t a = 255; | |
}; | |
RGBA_8888 yuv2rgb(uint8_t y, uint8_t u, uint8_t v) { | |
int r = y + (1.370705 * (v - 128)); | |
int g = y - (0.698001 * (v - 128)) - (0.337633 * (u - 128));; | |
int b = y + (1.732446 * (u - 128)); | |
r = clamp(r, 0, 255); | |
g = clamp(g, 0, 255); | |
b = clamp(b, 0, 255); | |
return {.r = r, ,g = g, .b = b}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment