Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

IPP RGB24 to YV12 or I420 with no ippmirror

yann_stephan
Beginner
573 Views

Please find enclosed an example of a code that will convert a RGB24 to YV12 or I420 without using the ippMirror function as final step.

In fact the filling will be done form the bottom line to top line, by having a negative destination step.

Hope it can help.

Yann

BOOL CHPColorConverter::Convert_RGB24(IMediaSample * pIn, IMediaSample *pOut, AM_MEDIA_TYPE * pmtIn, AM_MEDIA_TYPE * pmtOut)
{

LPBYTEpData;
LPBYTEpVideoBuffer;
Ipp8u*pYUV[3];
intdstStep[3];

longlDataLen;// Holds length of any given sample
longlInDataLen, lOutDataLen;


if ((pIn != NULL) && (pOut != NULL))
{
if ((pIn->GetPointer(&pData) == S_OK) && (pOut->GetPointer(&pVideoBuffer) == S_OK))
{
lDataLen= pIn->GetSize();
lInDataLen= pIn->GetActualDataLength();
lOutDataLen= pOut->GetActualDataLength();

long lComputedSize= ((m_nOutWidth * m_nOutHeight) + (((m_nOutWidth / 2) * (m_nOutHeight/2)) * 2));

if (lOutDataLen >= lComputedSize)
{
//
IppiSize roiSize = {m_nInWidth, m_nInHeight};

pYUV[0]= (Ipp8u *) pVideoBuffer + (m_nOutWidth * m_nOutHeight) - m_nOutWidth;
pYUV[1]= (Ipp8u *) (pYUV[0] + m_nOutWidth + ((m_nOutWidth * m_nOutHeight) / 4)) ;
pYUV[2]= (Ipp8u *) (pYUV[1] + ((m_nOutWidth * m_nOutHeight) / 4));


// TODO : Try negative value
dstStep[0] = -m_nOutWidth;
dstStep[1] = -(m_nOutWidth / 2);
dstStep[2] = -(m_nOutWidth / 2);

if (pmtOut->subtype == MEDIASUBTYPE_YV12)
{
ippiRGBToYCbCr420_8u_C3P3R((const Ipp8u*) pData, m_nInWidth*3, pYUV, dstStep, roiSize);
}
else
{
ippiRGBToYUV420_8u_C3P3R((const Ipp8u*) pData, m_nInWidth*3, pYUV, dstStep, roiSize);
}

pOut->SetActualDataLength(lComputedSize);
return TRUE;
}
}
}

return FALSE;
}

0 Kudos
1 Reply
Vladimir_Dudnik
Employee
573 Views

Thank you Yann,good and useful tip.

Note, historically, not all IPP functions do support negative step, but we extending that list. If negative step is not supported functions will return error code (not access violation!).

Regards,
Vladimir

0 Kudos
Reply