- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;
}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page