Last active
August 29, 2015 13:56
-
-
Save ikriz/8952257 to your computer and use it in GitHub Desktop.
Method to Split YUV Planes
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
void SplitYUVPlanes(int width, int height, unsigned char *data, int size, unsigned char *yuvInput[3]) | |
{ | |
// live input *data is YUV444 Packed | |
// Conversion from 444 Packed -> 444 Planar | |
int index = 0; | |
int srcStride = size; | |
// need to flip image from bottom-up to top-down | |
int revheight = height - 1; | |
unsigned char* pLuma = yuvInput[0]; | |
unsigned char* pChromaU = yuvInput[1]; | |
unsigned char* pChromaV = yuvInput[2]; | |
for (int i = 0; i < height; ++i) | |
{ | |
// read bottom line first | |
int line = (revheight - i) * srcStride; | |
for (int j = 0; j < width; ++j) | |
{ | |
int idx = line + (j * 4); | |
pLuma[index] = data[idx + 2]; //Y | |
pChromaV[index] = data[idx + 1]; //V | |
pChromaU[index] = data[idx + 0]; //U | |
index++; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently this method is needs optimization if anyone is willing to help please do :)
The input pointer *data contains the data that needs to be split into different arrays and put in yuvInput