Skip to content

Instantly share code, notes, and snippets.

@ikriz
Last active August 29, 2015 13:56
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 ikriz/8952257 to your computer and use it in GitHub Desktop.
Save ikriz/8952257 to your computer and use it in GitHub Desktop.
Method to Split YUV Planes
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++;
}
}
}
@ikriz
Copy link
Author

ikriz commented Feb 12, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment