//sketch_buff - Temporary buffer for storing image in BGR format.
// Size of sketch_buff must be at least image_width*image_height*3 bytes.
void Rgb2NV12_709(const unsigned char I[],
const int image_width,
const int image_height,
unsigned char sketch_buff[],
unsigned char J[])
IppStatus ipp_status;
int srcStep = image_width*3;
int dstBgrStep = image_width*3;
int dstYStep = image_width;
int dstCbCrStep = image_width;
IppiSize roiSize = {image_width, image_height};
const Ipp8u* pRGB = (Ipp8u*)I;
Ipp8u* pBGR = (Ipp8u*)sketch_buff; //BGR image is stored in sketch_buff
Ipp8u *pDstY = (Ipp8u*)J; //Y color plane is the first image_width*image_height pixels of J.
Ipp8u *pDstCbCr = (Ipp8u*)&J[image_width*image_height]; //In NV12 format, UV plane starts below Y.
const int bgrOrder[3] = {2, 1, 0};
//Swap Red and Blue color channels - convert from RGB to BGR
//Store the result into sketch_buff (sketch buffer is allocated outside the function)
ipp_status = ippiSwapChannels_8u_C3R(pRGB, srcStep, pBGR, dstBgrStep, roiSize, bgrOrder);
//if (ipp_status != ippStsNoErr), Handle errors...