I want to learn how to use NEON to split YUYV into Y, U, and V planes to later feed the data as OpenGL textures to the GPU.
Currently, I am doing it in C++ like this:
/**
* TopOpenGL splitYuvPlanes()
* Purpose: splitYuvPlanes - Split YUYV into 3 arrays - one for each component
*
* @param data - input data
* @param size - input data size
* @param y - array to store output channels
* @param u - array to store output channels
* @param v - array to store output channels
*/
void TopOpenGL::splitYuvPlanes(unsigned char *data, int size, unsigned char *y, unsigned char *u, unsigned char *v)
{
// This case takes RGBA -> BGRA
// __asm__ volatile(
// "mov r3, r3, lsr #3\n" /* Divide number of pixels by 8 because we process them 8 at a time */
// "loopRGBA:\n"
// "vld4.8 {d0-d3}, [r1]!\n" /* Load 8 pixels into d0 through d2. d0 = R[0-7], d1 = G[0-7], d2 = B[0-7], d3 = A[0-7] */
// "subs r3, r3, #1\n" /* Decrement the loop counter */
// "vswp d0, d2\n" /* Swap R and B channels */
// "vst4.8 {d0-d3}, [r2]!\n" /* Store the RGBA into destination 8 pixels at a time */
// "bgt loopRGBA\n"
// "bx lr\n"
// );
for ( int c = 0 ; c < ( size - 4 ) ; c+=4 ) {
*y = *data; // Y0
data++;
*u = *data; // U0
u++;
*u = *data; // U0
data++;
y++;
*y = *data; // Y1
data++;
*v = *data; // V0
v++;
*v = *data; // V0
data++;
y++;
u++;
v++;
}
}
How can I do this splitting into char *y, char *u, and char *v using NEON? Thank you.
I've found this blog, but it doesn't quite do what I want. http://blog.lumberlabs.com/2011/04/efficiently-splitting-cbcr-plane-with.html