Skip to content

Instantly share code, notes, and snippets.

@mebjas
Created January 1, 2022 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mebjas/7296c81161386599e4abd946fab3da2d to your computer and use it in GitHub Desktop.
Save mebjas/7296c81161386599e4abd946fab3da2d to your computer and use it in GitHub Desktop.
Skeleton code of YUV to RGB
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