Hi all,
to thanks you of support given to me, i'll post the code to correctly convert from RGB888 to YUV420:
------------------------------------------------------
static TUint8 yuvTable[38016]; 38016 = 176*144*3/2
#define _R ((TInt32)(s[2]))
#define _G ((TInt32)(s[1]))
#define _B ((TInt32)(s[0]))
#define _BPP 3 // bytes per pixel, check color depth of source bitmap
LOCAL_C inline int Clamp255( TInt aVal )
{
if (aVal <= 0)
return 0;
if (aVal >= 255)
return 255;
return aVal;
}
void CMediaVideoRecord::PreparaYUVTable()
{
TInt index = iArrIndicesImages->operator [](iCurrentArrIndicesImage);
CFbsBitmap *iBitmap = new (ELeave) CFbsBitmap();
iBitmap->Load(_L("\\resource\\apps\\AlfaMitoSymbian_video.mbm"),index);
/**
* CONVERT FROM CFBSBITMAP TO YUV420
*/
iBitmap->LockHeap(EFalse);
TUint8* s = (TUint8*)iBitmap->DataAddress();
TInt iScanlineLen = CFbsBitmap::ScanLineLength(iBitmap->SizeInPixels().iWidth,
iBitmap->DisplayMode());
HBufC8* iScanline = HBufC8::NewL(iScanlineLen);
iScanline->Des().Copy(s, iScanlineLen);
Mem::Copy(s, (s+iScanlineLen), iScanlineLen*143);
Mem::Copy((s+iScanlineLen*143), iScanline->Des().Ptr(), iScanlineLen);
TInt ui = 176*144;
TInt vi = 176*144 + (176*144)/4;
TInt i = 0;
for(TInt j=0; j < 144; j++)
for(TInt k=0; k < 176; k++)
{
yuvTable[i] = (TUint8)( ( 66*_R + 129*_G + 25*_B + 128) >> 8 ) + 16;
// U, V values (planar 420), so each U and V covers 2*2 pixels
if(0 == j%2 && 0 == k%2)
{
yuvTable[ui++] = (TUint8)Clamp255(( ( -38*_R - 74*_G + 112*_B + 128) >> 8 ) + 128 );
yuvTable[vi++] = (TUint8)Clamp255(( ( 112*_R - 94*_G - 18*_B + 128) >> 8 ) + 128 );
}
i++; s+=_BPP;
}
iBitmap->UnlockHeap(EFalse);
/**
* CONVERT FROM CFBSBITMAP TO YUV420
*/
delete iBitmap;
}
------------------------------------------------------




