mdfdevvideoextensions/nga_mdf_postprocessor/src/NGAPostProcHwDevice.cpp
branchRCL_3
changeset 14 cd271b19d824
parent 12 b74061f7f3d2
child 19 8184f75a63d4
equal deleted inserted replaced
12:b74061f7f3d2 14:cd271b19d824
    17 
    17 
    18 
    18 
    19 #include "NGAPostProcHwDevice.h"
    19 #include "NGAPostProcHwDevice.h"
    20 #include "NGAPostProcSessionManager.h"
    20 #include "NGAPostProcSessionManager.h"
    21 #include "NGAPostProcSurfaceHandler.h"
    21 #include "NGAPostProcSurfaceHandler.h"
    22 #include "common.h"
       
    23 
    22 
    24 // post-processor info
    23 // post-processor info
    25 const TUid KUidVideoPostProcHwDevice = {KUidNGAPostProcHwDeviceImplUid};
    24 const TUid KUidVideoPostProcHwDevice = {KUidNGAPostProcHwDeviceImplUid};
    26 _LIT(KManufacturer, "Nokia Inc.");
    25 _LIT(KManufacturer, "Nokia Inc.");
    27 _LIT(KIdentifier, "Nokia S60 Video Post Processor Hardware Device Plugin");
    26 _LIT(KIdentifier, "Nokia S60 Video Post Processor Hardware Device Plugin");
    45 #endif
    44 #endif
    46 
    45 
    47 int32 gColorConvYUVtoYUV422Int (tBaseVideoFrame *yuv420Frame, tBaseVideoFrame* yuv422Frame,
    46 int32 gColorConvYUVtoYUV422Int (tBaseVideoFrame *yuv420Frame, tBaseVideoFrame* yuv422Frame,
    48 							   uint8 outClrFmt, int16 stride); 
    47 							   uint8 outClrFmt, int16 stride); 
    49 
    48 
       
    49 int32 Emz_VDec_gColorConv_YUVtoRGB ( 
       
    50 	  tBaseVideoFrame *srcImage, uint8 *dstImage, tWndParam *srcWindow, 
       
    51 	  tWndParam *dstWindow, uint8 srcImageFormat, uint8 dstImageFormat,
       
    52 	  uint8 colorConvScheme);
       
    53 		 	  
    50 #ifdef __cplusplus
    54 #ifdef __cplusplus
    51 }
    55 }
    52 #endif
    56 #endif
    53 
    57 
    54 //**************************************************
    58 //**************************************************
   173     if (iSurfaceHandler)
   177     if (iSurfaceHandler)
   174     {
   178     {
   175     	if(!iSurfaceId.IsNull())
   179     	if(!iSurfaceId.IsNull())
   176     	{
   180     	{
   177     		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::UnregisterSurface"), this);
   181     		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::UnregisterSurface"), this);
   178     		for(TInt i=0;i < iWsSession.NumberOfScreens();i++)
   182     		iWsSession.UnregisterSurface(0, iSurfaceId);
   179     		{
       
   180     			iWsSession.UnregisterSurface(i, iSurfaceId);
       
   181     		}
       
   182         	iSurfaceHandler->DestroySurface(iSurfaceId);
   183         	iSurfaceHandler->DestroySurface(iSurfaceId);
   183     	}
   184     	}
   184         delete iSurfaceHandler;
   185         delete iSurfaceHandler;
   185         iSurfaceHandler = NULL;
   186         iSurfaceHandler = NULL;
   186     }
   187     }
   204     {
   205     {
   205 				PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputFormatL() FAILED: Unexpected state"), this);
   206 				PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputFormatL() FAILED: Unexpected state"), this);
   206         User::Leave(KErrNotReady);
   207         User::Leave(KErrNotReady);
   207 	  }
   208 	  }
   208 
   209 
   209 
   210 		iVideoFormat = aFormat; 
   210 		if( ((aFormat.iYuvFormat.iPattern == EYuv420Chroma1) ||
   211 		if( ((iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma1) ||
   211 			(aFormat.iYuvFormat.iPattern == EYuv420Chroma2) ||
   212 			(iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma2) ||
   212     		(aFormat.iYuvFormat.iPattern == EYuv420Chroma3) ))
   213     		(iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma3) ))
   213 		{
   214 		{
       
   215 			iVideoFormat.iYuvFormat.iCoefficients  	     = EYuvBt709Range1;
       
   216     		iVideoFormat.iYuvFormat.iPattern       	     = EYuv422Chroma1;
       
   217     		iVideoFormat.iYuvFormat.iDataLayout          = EYuvDataInterleavedBE;
       
   218 			
   214 #if defined __WINSCW__				
   219 #if defined __WINSCW__				
   215 				iIsColorConversionNeeded = ETrue; 
   220 				iIsColorConversionNeeded = ETrue; 
   216 #else
   221 #else
   217 				iAttributes().iPixelFormat = EUidPixelFormatYUV_420Planar;
   222 				iAttributes().iPixelFormat = EUidPixelFormatYUV_420Planar;
   218 #endif //__WINSCW__
   223 #endif //__WINSCW__
   357    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize --"), this);
   362    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize --"), this);
   358 }
   363 }
   359 
   364 
   360 void CNGAPostProcHwDevice::WritePictureL(TVideoPicture* aPicture) 
   365 void CNGAPostProcHwDevice::WritePictureL(TVideoPicture* aPicture) 
   361 { 
   366 { 
   362 	PP_DEBUG(_L("CNGAPostProcHwDevice:WritePicture ++"));
   367 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePicture bufId = %d"), this,GetID(aPicture));
   363 	TVideoPicture* pic;
   368 	TVideoPicture* pic;
   364 	if (iPPState==EInitializing || iPPState==EStopped || iIsInputEnded)
   369 	if (iPPState==EInitializing || iPPState==EStopped || iIsInputEnded)
   365     {
   370     {
   366 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: Unexpected state"), this);
   371 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: Unexpected state"), this);
   367         User::Leave(KErrNotReady);
   372         User::Leave(KErrNotReady);
   371     {
   376     {
   372 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: Invalid argument"), this);
   377 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: Invalid argument"), this);
   373 		User::Leave(KErrArgument);
   378 		User::Leave(KErrArgument);
   374 	}
   379 	}
   375 	pic = aPicture;	
   380 	pic = aPicture;	
   376     if (iInputQ.Count() > 0)
   381 	iPictureCounters.iTotalPictures++;
   377     {
   382 	if((iPPState != EPlaying) && (iFirstPictureUpdated))
   378         AddToQ(pic);
   383 	{
   379         AttemptToPost();
   384 		AddToQ(pic);
   380     }
   385 	}
   381     else
   386 	else if( iInputQ.Count() > 0 )
   382     {
   387 	{
   383 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePicture bufId = %d"), this,GetID(pic));
   388 		AddToQ(pic);
   384 		iPictureCounters.iTotalPictures++;
   389 		AttemptToPost();
       
   390 	}
       
   391 	else
       
   392 	{
   385 		TInt64 delta = 0;
   393 		TInt64 delta = 0;
   386 		TTimeToPost iTimeToPost = (TTimeToPost)IsTimeToPost(pic, delta);
   394 		TTimeToPost iTimeToPost = (TTimeToPost)IsTimeToPost(pic, delta);
   387 		if(!IsGceReady())
   395 		if(!IsGceReady())
   388 	    {  
   396 	    {  
   389 			PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL GCE not ready"), this );
   397 			PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL GCE not ready"), this );
   395 	    if (delta > 0x7FFFFFFF)
   403 	    if (delta > 0x7FFFFFFF)
   396 	    {
   404 	    {
   397 	         PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL Too large delta .. skipping"), this ); 
   405 	         PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL Too large delta .. skipping"), this ); 
   398 	         iTimeToPost = ESkipIt;
   406 	         iTimeToPost = ESkipIt;
   399 	    }
   407 	    }
   400 	
   408 		if(!iFirstPictureUpdated)
       
   409 		{
       
   410 			iTimeToPost = EPostIt;
       
   411 		}
   401 		switch(iTimeToPost)
   412 		switch(iTimeToPost)
   402 		{
   413 		{
   403 			case EDelayIt:
   414 			case EDelayIt:
   404 			{
   415 			{
   405 				if(AddToQ(pic) != 0)
   416 				if(AddToQ(pic) != 0)
   868 
   879 
   869 void CNGAPostProcHwDevice::Start() 
   880 void CNGAPostProcHwDevice::Start() 
   870 {  
   881 {  
   871 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Start ++"), this);
   882 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Start ++"), this);
   872 	iPPState = EPlaying;
   883 	iPPState = EPlaying;
       
   884 	AttemptToPost();
   873 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Start --"), this);
   885 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Start --"), this);
   874 }
   886 }
   875 
   887 
   876 void CNGAPostProcHwDevice::Stop() 
   888 void CNGAPostProcHwDevice::Stop() 
   877 { 
   889 { 
   977 
   989 
   978 void CNGAPostProcHwDevice::ReturnPicture(TVideoPicture* ) 
   990 void CNGAPostProcHwDevice::ReturnPicture(TVideoPicture* ) 
   979 { 
   991 { 
   980 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReturnPicture +-"), this);
   992 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReturnPicture +-"), this);
   981     //not required for direct rendering 
   993     //not required for direct rendering 
       
   994 }
       
   995 
       
   996 TBool CNGAPostProcHwDevice::GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& /*aFormat*/)
       
   997 { 
       
   998 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL %d %d ++"), this, iVBMEnabled, iProcessQ.Count());
       
   999 	TVideoPicture* 		pic = NULL;
       
  1000 	TInt 				err = KErrNone;
       
  1001 	TBool				frameAvailable =EFalse;
       
  1002 	tWndParam			inputCropWindow;
       
  1003 	tWndParam			outputCropWindow;
       
  1004 	tBaseVideoFrame		inputFrame;
       
  1005 	inputFrame.lum 		= NULL; 
       
  1006 	
       
  1007 	if(aPictureData.iDataFormat == ERgbFbsBitmap)
       
  1008 	{	
       
  1009 		if(iProcessQ.Count())
       
  1010 		{
       
  1011 			pic = iProcessQ[0]; //frame already submitted for display
       
  1012 		}
       
  1013 		else if(iInputQ.Count())
       
  1014 		{
       
  1015 			pic = iInputQ[0]; //frame yet to be displayed
       
  1016 		}
       
  1017 		if(pic) 
       
  1018 		{
       
  1019 			if (iVBMEnabled)
       
  1020 		    {
       
  1021 				inputFrame.lum	= (TUint8*)pic->iData.iRawData->Ptr();
       
  1022 			}
       
  1023 			else
       
  1024 			{
       
  1025 				if (iInputDecoderDevice)
       
  1026 				{
       
  1027 					MMmfVideoFetchFrame* VFHandler = NULL;
       
  1028 					VFHandler = (MMmfVideoFetchFrame*)iInputDecoderDevice->CustomInterface(KUidMMFVideoFetchFrame);
       
  1029 					if (VFHandler)
       
  1030 					{
       
  1031 						PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL() fetch frame"), this);
       
  1032 						inputFrame.lum = (TUint8*)VFHandler->MmvffGetFrame(GetID(pic));
       
  1033 					}
       
  1034 					else
       
  1035 					{
       
  1036 						PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL() decoder yet to implement MMmfVideoFetchFrame CI"), this);
       
  1037 					}
       
  1038 				}
       
  1039 			}
       
  1040 		}
       
  1041 		if(inputFrame.lum)
       
  1042 		{
       
  1043 			inputFrame.cb	= inputFrame.lum + iPicSize.iWidth * iPicSize.iHeight;
       
  1044 			
       
  1045 			if( ((iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma1) ||
       
  1046 				(iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma2) ||
       
  1047 	    		(iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma3) ))						
       
  1048 			{
       
  1049 				inputFrame.cr = inputFrame.lum + (iPicSize.iWidth * iPicSize.iHeight*5)/4;
       
  1050 			}
       
  1051 			else
       
  1052 			{
       
  1053 				inputFrame.cr = inputFrame.lum + (iPicSize.iWidth * iPicSize.iHeight*3)/2;
       
  1054 			}
       
  1055 			
       
  1056 			inputFrame.width	= (unsigned short)iPicSize.iWidth;
       
  1057 			inputFrame.height	= (unsigned short)iPicSize.iHeight;
       
  1058 			
       
  1059 			outputCropWindow.wndHeight  = iPicSize.iHeight;	
       
  1060 			outputCropWindow.wndWidth	= iPicSize.iWidth; 	
       
  1061 			outputCropWindow.xOffset	= 0;
       
  1062 			outputCropWindow.yOffset	= 0;
       
  1063 			
       
  1064 			inputCropWindow.wndHeight  = iPicSize.iHeight;	
       
  1065 			inputCropWindow.wndWidth	= iPicSize.iWidth; 	
       
  1066 			inputCropWindow.xOffset	= 0;
       
  1067 			inputCropWindow.yOffset	= 0;
       
  1068 			
       
  1069 			RFbsSession fbs;
       
  1070 			fbs.Connect();
       
  1071 			CFbsBitmap* iOutBitmap = aPictureData.iRgbBitmap;
       
  1072 			TInt status = iOutBitmap->Resize(iPicSize);
       
  1073 			if (status == KErrNone)
       
  1074 			{
       
  1075 				// Lock the heap to prevent the FBS server from invalidating the address
       
  1076 		        iOutBitmap->LockHeap();
       
  1077 		        TUint8* dataAddress = (TUint8*)iOutBitmap->DataAddress();
       
  1078 				err = ColorConvert(&inputFrame, dataAddress, &inputCropWindow, &outputCropWindow);
       
  1079 				iOutBitmap->UnlockHeap();
       
  1080 				frameAvailable = ETrue;
       
  1081 			}
       
  1082 			fbs.Disconnect();
       
  1083 		}
       
  1084 	}
       
  1085 	else
       
  1086 	{
       
  1087 		err = KErrNotSupported;
       
  1088 	}
       
  1089 	if(err != KErrNone)
       
  1090 	{
       
  1091 		User::Leave(err);
       
  1092 	}
       
  1093 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL --"), this);
       
  1094 	return(frameAvailable);
   982 }
  1095 }
   983 
  1096 
   984 void CNGAPostProcHwDevice::InputEnd() 
  1097 void CNGAPostProcHwDevice::InputEnd() 
   985 { 
  1098 { 
   986    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:InputEnd ++"), this);
  1099    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:InputEnd ++"), this);
  1216         User::Leave(KErrNotSupported);
  1329         User::Leave(KErrNotSupported);
  1217 		}
  1330 		}
  1218 		
  1331 		
  1219 		if(iVBMBufferReferenceQ.Count() == 0)
  1332 		if(iVBMBufferReferenceQ.Count() == 0)
  1220 		{
  1333 		{
  1221 				err = SetupSurface(aSize);
  1334 			iPicSize = aSize;
  1222 				if(err)
  1335 			err = SetupSurface(aSize);
  1223 				{
  1336 			if(err)
  1224 						PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() Surface Setup Failed %d"), this, err);
  1337 			{
  1225 						User::Leave(err);
  1338 					PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() Surface Setup Failed %d"), this, err);
  1226 				}
  1339 					User::Leave(err);
       
  1340 			}
  1227 		}
  1341 		}
  1228 		
  1342 		
  1229     if(!iVBMBufferQ.Count())
  1343     if(!iVBMBufferQ.Count())
  1230     {
  1344     {
  1231        PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() WARNING: Queue buffer count zero"), this);
  1345        PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() WARNING: Queue buffer count zero"), this);
  1300 {
  1414 {
  1301 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL()++"), this);
  1415 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL()++"), this);
  1302 	if(!aSurfaceId.IsNull())
  1416 	if(!aSurfaceId.IsNull())
  1303 	{
  1417 	{
  1304 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL(): UnregisterSurface ID = 0x%x"), this, aSurfaceId );
  1418 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL(): UnregisterSurface ID = 0x%x"), this, aSurfaceId );
  1305 		for(TInt i=0;i < iWsSession.NumberOfScreens();i++)
  1419 		iWsSession.UnregisterSurface(0, iSurfaceId);
  1306 		{
       
  1307 			iWsSession.UnregisterSurface(i, aSurfaceId);
       
  1308 		}
       
  1309 		iSurfaceHandler->DestroySurface(aSurfaceId);
  1420 		iSurfaceHandler->DestroySurface(aSurfaceId);
  1310 	}
  1421 	}
  1311 		
  1422 		
  1312 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL() --"), this);
  1423 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL() --"), this);
  1313 }
  1424 }
  1699     TInt resp = EPostIt;
  1810     TInt resp = EPostIt;
  1700     // Frame presentation time
  1811     // Frame presentation time
  1701     TInt64 uPresTime = frame->iTimestamp.Int64();
  1812     TInt64 uPresTime = frame->iTimestamp.Int64();
  1702       
  1813       
  1703     // Check if this is an out of order frame in case of forward playback
  1814     // Check if this is an out of order frame in case of forward playback
  1704     if((iCurrentPlaybackPosition.Int64() >= uPresTime) && (iPlayRate > 0))    
  1815     if((iCurrentPlaybackPosition.Int64() > uPresTime) && (iPlayRate > 0))    
  1705     {      
  1816     {      
  1706          PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost : Out of order frame (forward playback) Tfm=%d"), this,(TInt)uPresTime);
  1817          PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost : Out of order frame (forward playback) Tfm=%d"), this,(TInt)uPresTime);
  1707          resp = ESkipIt;  //drop      
  1818          resp = ESkipIt;  //drop      
  1708     }      // Check if this is an out of order frame in case of backward playback
  1819     }      // Check if this is an out of order frame in case of backward playback
  1709     else if((iCurrentPlaybackPosition.Int64() <= uPresTime) && (iPlayRate < 0))    
  1820     else if((iCurrentPlaybackPosition.Int64() < uPresTime) && (iPlayRate < 0))    
  1710     {      
  1821     {      
  1711         PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost : Out of order frame (backward playback) Tfm=%d"), this,(TInt)uPresTime);
  1822         PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost : Out of order frame (backward playback) Tfm=%d"), this,(TInt)uPresTime);
  1712         resp = ESkipIt;  //drop      
  1823         resp = ESkipIt;  //drop      
  1713     }
  1824     }
  1714     else if (iClockSource)
  1825     else if (iClockSource)
  1727             resp = ESkipIt;  //drop
  1838             resp = ESkipIt;  //drop
  1728         }
  1839         }
  1729        PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost .. Tfm=%d, Tcs=%d, delta=%d"), this, (TInt)uPresTime, (TInt)uSyncTime, (TInt)delta);
  1840        PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost .. Tfm=%d, Tcs=%d, delta=%d"), this, (TInt)uPresTime, (TInt)uSyncTime, (TInt)delta);
  1730     }       
  1841     }       
  1731    
  1842    
  1732    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost -- %d"), this, resp);
  1843    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost -- %d BufID = %d"), this, resp, GetID(frame));
  1733     return resp;
  1844     return resp;
  1734 }
  1845 }
  1735 
  1846 
  1736 void CNGAPostProcHwDevice::ReleaseInputQ()
  1847 void CNGAPostProcHwDevice::ReleaseInputQ()
  1737 {
  1848 {
  1912 }
  2023 }
  1913 
  2024 
  1914 TInt CNGAPostProcHwDevice::RegisterSurface(const TSurfaceId& aSurfaceId)
  2025 TInt CNGAPostProcHwDevice::RegisterSurface(const TSurfaceId& aSurfaceId)
  1915 {
  2026 {
  1916 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:RegisterSurface(): RegisterSurface ID = 0x%x"), this, aSurfaceId);
  2027 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:RegisterSurface(): RegisterSurface ID = 0x%x"), this, aSurfaceId);
  1917 	TInt err = KErrNone;
  2028 	return(iWsSession.RegisterSurface(0, aSurfaceId));
  1918 	for(TInt i=0; (i < iWsSession.NumberOfScreens() && err == KErrNone); i++)
       
  1919 	{
       
  1920 		err = iWsSession.RegisterSurface(i, aSurfaceId);
       
  1921 	}	
       
  1922 	return(err);
       
  1923 }
  2029 }
  1924 
  2030 
  1925 TInt CNGAPostProcHwDevice::IsGceReady()
  2031 TInt CNGAPostProcHwDevice::IsGceReady()
  1926 {
  2032 {
  1927     if(iProcessQ.Count() >= KMaxBuffersGceCanHold)
  2033     if(iProcessQ.Count() >= KMaxBuffersGceCanHold)
  2151    }
  2257    }
  2152    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints. err = %d --"), this,err);
  2258    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints. err = %d --"), this,err);
  2153    return err;
  2259    return err;
  2154 }
  2260 }
  2155 
  2261 
       
  2262 TInt CNGAPostProcHwDevice::ColorConvert(tBaseVideoFrame* aInputFrame, TUint8* aDestPtr, tWndParam* aInputCropWindow, tWndParam* aOutputCropWindow)
       
  2263 {
       
  2264 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ColorConvert ++"), this);
       
  2265 	__ASSERT_ALWAYS(aDestPtr, User::Invariant());
       
  2266 	TInt				lError = E_SUCCESS;
       
  2267 	TInt				err = KErrNone;
       
  2268 	
       
  2269 	err = SetSourceFormat();
       
  2270 	if(err == KErrNone)
       
  2271 	{
       
  2272     	err = SetSourceRange();
       
  2273     	if(err == KErrNone)
       
  2274     	{
       
  2275 						
       
  2276 			lError = Emz_VDec_gColorConv_YUVtoRGB(aInputFrame,aDestPtr, 
       
  2277 						aInputCropWindow, aOutputCropWindow, iSourceFormat,
       
  2278 						EBitmapColor16MU, iSourceRange);
       
  2279 
       
  2280 			if(lError)
       
  2281 			{
       
  2282 				if(lError == E_OUT_OF_MEMORY)
       
  2283 					{
       
  2284 					err = KErrNoMemory;
       
  2285 					}
       
  2286 				else if(lError == E_FAILURE)
       
  2287 					{
       
  2288 					err = KErrNotSupported;
       
  2289 					}
       
  2290 				else
       
  2291 					{
       
  2292 					err = KErrGeneral;
       
  2293 					}
       
  2294 			}
       
  2295 		}
       
  2296 	}
       
  2297 	
       
  2298 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ColorConvert --"), this);
       
  2299 	return err;
       
  2300 }
       
  2301 
       
  2302 TInt CNGAPostProcHwDevice::SetSourceFormat()
       
  2303 {
       
  2304 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceFormatL ++"), this);
       
  2305 	TInt err = KErrNone;
       
  2306 	switch (iVideoFormat.iYuvFormat.iPattern)
       
  2307 	{
       
  2308 	    case EYuv420Chroma1:
       
  2309     		iSourceFormat = EYuv420Chroma1_Planar;
       
  2310     		break;
       
  2311         case EYuv420Chroma2:
       
  2312     		iSourceFormat = EYuv420Chroma2_Planar;
       
  2313     		break;
       
  2314         case EYuv420Chroma3:
       
  2315     		iSourceFormat = EYuv420Chroma3_Planar;
       
  2316     		break;
       
  2317 	    case EYuv422Chroma1:
       
  2318 			if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedLE)
       
  2319     			iSourceFormat = EYuv422Chroma1_LE;
       
  2320 	    	else if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedBE )
       
  2321 				iSourceFormat = EYuv422Chroma1_BE;
       
  2322 			else
       
  2323 			    err = KErrArgument;
       
  2324 			break;
       
  2325     	case EYuv422Chroma2:
       
  2326     		if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedLE)
       
  2327 	    		iSourceFormat = EYuv422Chroma2_LE;
       
  2328     		else if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedBE )
       
  2329     			iSourceFormat = EYuv422Chroma2_BE;
       
  2330 			else
       
  2331 			    err = KErrArgument;
       
  2332 			break;
       
  2333       default:
       
  2334     		err = KErrNotSupported;
       
  2335 	}
       
  2336 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceFormatL --"), this);
       
  2337 	return err;
       
  2338 }
       
  2339 
       
  2340 
       
  2341 TInt CNGAPostProcHwDevice::SetSourceRange()
       
  2342 {
       
  2343 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceRangeL ++"), this);
       
  2344 	TInt err = KErrNone;
       
  2345 	switch (iVideoFormat.iYuvFormat.iCoefficients)
       
  2346 	{
       
  2347 	    case EYuvBt601Range0:
       
  2348 			iSourceRange = EITU601_5_REDUCEDRANGE;
       
  2349             break;
       
  2350         case EYuvBt601Range1:
       
  2351 			iSourceRange = EITU601_5_FULLRANGE;
       
  2352 			break;
       
  2353         case EYuvBt709Range0:
       
  2354 			iSourceRange = EB709_REDUCEDRANGE;
       
  2355 			break;
       
  2356         case EYuvBt709Range1:
       
  2357 			iSourceRange = EB709_FULLRANGE;
       
  2358             break;
       
  2359 	    default:
       
  2360 		    err = KErrNotSupported;
       
  2361     }
       
  2362     PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceRangeL --"), this);
       
  2363     return err;
       
  2364 }
       
  2365 
  2156 CNGAPostProcTimer::CNGAPostProcTimer( CNGAPostProcHwDevice& aParent )
  2366 CNGAPostProcTimer::CNGAPostProcTimer( CNGAPostProcHwDevice& aParent )
  2157 :CTimer(EPriorityHigh),iParent(aParent)
  2367 :CTimer(EPriorityHigh),iParent(aParent)
  2158 {
  2368 {
  2159 	CActiveScheduler::Add(this);
  2369 	CActiveScheduler::Add(this);
  2160 }
  2370 }