I am looking for some advices how to speed up the following operation. Is there some STL library function, or opencv or Intel IPP function that I can use?
I have a 3840 x 2160 image buffer containing BGRA pixel-packed data. the image is interleaved from two camera sources. i.e. the memory layout is as follows
left eye row 1 ;
right eye row 1 ;
left eye row 2 ;
right eye row 2 ;
...
left eye row 1080 ;
right eye row 1080 ;
Now I need to split left and right so that in the new image buffer the first half ( the top half) is left eye and the second half (bottom half) is right eye.
new image frame:
left eye row 1 ;
left eye row 2 ;
...
left eye row 1080 ;
right eye row 1 ;
right eye row 2 ;
...
right eye row 1080 ;
//here is my current code.
unsigned char* data; //data points to the original interleaved buffer
unsigned char top_bottom_frame [3840 * 2160 * 4]; //left right de-interleaved frame
const int stride = 4* 3840;
//copy left eye rows
for(int i=0, j=0; i< 2160; i = i+2, ++j)
{
memcpy(&top_bottom_frame[j*stride], data + i * stride, stride);
}
//copy right eye rows
for(int i=1, j= 1080 ; i<2160; i = i+2, ++j)
{
memcpy(&top_bottom_frame[j*stride], data + i * stride, stride);
}