mdfdevvideoextensions/nga_mdf_postprocessor/src/NGAPostProcHwDevice.cpp
changeset 18 72dc595b34a8
parent 15 c1e808730d6c
child 21 1c0a769d0cc5
equal deleted inserted replaced
15:c1e808730d6c 18:72dc595b34a8
    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 //**************************************************
   140     
   144     
   141     while (iVBMBufferReferenceQ.Count()>0)
   145     while (iVBMBufferReferenceQ.Count()>0)
   142     {
   146     {
   143         TVideoPicture* pic = iVBMBufferReferenceQ[0];
   147         TVideoPicture* pic = iVBMBufferReferenceQ[0];
   144         iVBMBufferReferenceQ.Remove(0);
   148         iVBMBufferReferenceQ.Remove(0);
       
   149         if (iColorConversionQ.Count()>0)
       
   150     	{
       
   151 	        iColorConversionQ.Remove(0);
       
   152 	    }
   145 
   153 
   146         if (pic->iHeader) delete pic->iHeader;
   154         if (pic->iHeader) delete pic->iHeader;
   147         delete pic->iData.iRawData;
   155         delete pic->iData.iRawData;
   148         delete pic;
   156         delete pic;
   149     }
   157     }
   151     iSupportedInputFormats.Reset();
   159     iSupportedInputFormats.Reset();
   152     iSupportedInputFormats.Close();
   160     iSupportedInputFormats.Close();
   153     
   161     
   154     iVBMBufferReferenceQ.Reset();
   162     iVBMBufferReferenceQ.Reset();
   155     iVBMBufferReferenceQ.Close();
   163     iVBMBufferReferenceQ.Close();
       
   164     
       
   165     iColorConversionQ.Reset();
       
   166     iColorConversionQ.Close();
   156     
   167     
   157     iVBMBufferQ.Reset();
   168     iVBMBufferQ.Reset();
   158     iVBMBufferQ.Close();
   169     iVBMBufferQ.Close();
   159     
   170     
   160     iProcessQ.Reset();
   171     iProcessQ.Reset();
   194     {
   205     {
   195 				PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputFormatL() FAILED: Unexpected state"), this);
   206 				PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputFormatL() FAILED: Unexpected state"), this);
   196         User::Leave(KErrNotReady);
   207         User::Leave(KErrNotReady);
   197 	  }
   208 	  }
   198 
   209 
   199 
   210 		iVideoFormat = aFormat; 
   200 		if( ((aFormat.iYuvFormat.iPattern == EYuv420Chroma1) ||
   211 		if( ((iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma1) ||
   201 			(aFormat.iYuvFormat.iPattern == EYuv420Chroma2) ||
   212 			(iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma2) ||
   202     		(aFormat.iYuvFormat.iPattern == EYuv420Chroma3) ))
   213     		(iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma3) ))
   203 		{
   214 		{
       
   215 			iVideoFormat.iYuvFormat.iCoefficients  	     = EYuvBt709Range1;
       
   216     		iVideoFormat.iYuvFormat.iPattern       	     = EYuv422Chroma1;
       
   217     		iVideoFormat.iYuvFormat.iDataLayout          = EYuvDataInterleavedBE;
       
   218 			
   204 #if defined __WINSCW__				
   219 #if defined __WINSCW__				
   205 				iIsColorConversionNeeded = ETrue; 
   220 				iIsColorConversionNeeded = ETrue; 
   206 #else
   221 #else
   207 				iAttributes().iPixelFormat = EUidPixelFormatYUV_420Planar;
   222 				iAttributes().iPixelFormat = EUidPixelFormatYUV_420Planar;
   208 #endif //__WINSCW__
   223 #endif //__WINSCW__
   347    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize --"), this);
   362    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize --"), this);
   348 }
   363 }
   349 
   364 
   350 void CNGAPostProcHwDevice::WritePictureL(TVideoPicture* aPicture) 
   365 void CNGAPostProcHwDevice::WritePictureL(TVideoPicture* aPicture) 
   351 { 
   366 { 
   352 	PP_DEBUG(_L("CNGAPostProcHwDevice:WritePicture ++"));
   367 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePicture bufId = %d"), this,GetID(aPicture));
   353 	TVideoPicture* pic;
   368 	TVideoPicture* pic;
   354 	if (iPPState==EInitializing || iPPState==EStopped || iIsInputEnded)
   369 	if (iPPState==EInitializing || iPPState==EStopped || iIsInputEnded)
   355     {
   370     {
   356 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: Unexpected state"), this);
   371 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: Unexpected state"), this);
   357         User::Leave(KErrNotReady);
   372         User::Leave(KErrNotReady);
   361     {
   376     {
   362 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: Invalid argument"), this);
   377 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: Invalid argument"), this);
   363 		User::Leave(KErrArgument);
   378 		User::Leave(KErrArgument);
   364 	}
   379 	}
   365 	pic = aPicture;	
   380 	pic = aPicture;	
   366     if (iInputQ.Count() > 0)
   381 	iPictureCounters.iTotalPictures++;
   367     {
   382 	if((iPPState != EPlaying) && (iFirstPictureUpdated))
   368         AddToQ(pic);
   383 	{
   369         AttemptToPost();
   384 		AddToQ(pic);
   370     }
   385 	}
   371     else
   386 	else if( iInputQ.Count() > 0 )
   372     {
   387 	{
   373 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePicture bufId = %d"), this,GetID(pic));
   388 		AddToQ(pic);
   374 		iPictureCounters.iTotalPictures++;
   389 		AttemptToPost();
       
   390 	}
       
   391 	else
       
   392 	{
   375 		TInt64 delta = 0;
   393 		TInt64 delta = 0;
   376 		TTimeToPost iTimeToPost = (TTimeToPost)IsTimeToPost(pic, delta);
   394 		TTimeToPost iTimeToPost = (TTimeToPost)IsTimeToPost(pic, delta);
   377 		if(!IsGceReady())
   395 		if(!IsGceReady())
   378 	    {  
   396 	    {  
   379 			PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL GCE not ready"), this );
   397 			PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL GCE not ready"), this );
   385 	    if (delta > 0x7FFFFFFF)
   403 	    if (delta > 0x7FFFFFFF)
   386 	    {
   404 	    {
   387 	         PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL Too large delta .. skipping"), this ); 
   405 	         PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL Too large delta .. skipping"), this ); 
   388 	         iTimeToPost = ESkipIt;
   406 	         iTimeToPost = ESkipIt;
   389 	    }
   407 	    }
   390 	
   408 		if(!iFirstPictureUpdated)
       
   409 		{
       
   410 			iTimeToPost = EPostIt;
       
   411 		}
   391 		switch(iTimeToPost)
   412 		switch(iTimeToPost)
   392 		{
   413 		{
   393 			case EDelayIt:
   414 			case EDelayIt:
   394 			{
   415 			{
   395 				if(AddToQ(pic) != 0)
   416 				if(AddToQ(pic) != 0)
   858 
   879 
   859 void CNGAPostProcHwDevice::Start() 
   880 void CNGAPostProcHwDevice::Start() 
   860 {  
   881 {  
   861 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Start ++"), this);
   882 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Start ++"), this);
   862 	iPPState = EPlaying;
   883 	iPPState = EPlaying;
       
   884 	AttemptToPost();
   863 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Start --"), this);
   885 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Start --"), this);
   864 }
   886 }
   865 
   887 
   866 void CNGAPostProcHwDevice::Stop() 
   888 void CNGAPostProcHwDevice::Stop() 
   867 { 
   889 { 
   967 
   989 
   968 void CNGAPostProcHwDevice::ReturnPicture(TVideoPicture* ) 
   990 void CNGAPostProcHwDevice::ReturnPicture(TVideoPicture* ) 
   969 { 
   991 { 
   970 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReturnPicture +-"), this);
   992 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReturnPicture +-"), this);
   971     //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);
   972 }
  1095 }
   973 
  1096 
   974 void CNGAPostProcHwDevice::InputEnd() 
  1097 void CNGAPostProcHwDevice::InputEnd() 
   975 { 
  1098 { 
   976    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:InputEnd ++"), this);
  1099    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:InputEnd ++"), this);
  1206         User::Leave(KErrNotSupported);
  1329         User::Leave(KErrNotSupported);
  1207 		}
  1330 		}
  1208 		
  1331 		
  1209 		if(iVBMBufferReferenceQ.Count() == 0)
  1332 		if(iVBMBufferReferenceQ.Count() == 0)
  1210 		{
  1333 		{
  1211 				err = SetupSurface(aSize);
  1334 			iPicSize = aSize;
  1212 				if(err)
  1335 			err = SetupSurface(aSize);
  1213 				{
  1336 			if(err)
  1214 						PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() Surface Setup Failed %d"), this, err);
  1337 			{
  1215 						User::Leave(err);
  1338 					PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() Surface Setup Failed %d"), this, err);
  1216 				}
  1339 					User::Leave(err);
       
  1340 			}
  1217 		}
  1341 		}
  1218 		
  1342 		
  1219     if(!iVBMBufferQ.Count())
  1343     if(!iVBMBufferQ.Count())
  1220     {
  1344     {
  1221        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);
  1290 {
  1414 {
  1291 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL()++"), this);
  1415 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL()++"), this);
  1292 	if(!aSurfaceId.IsNull())
  1416 	if(!aSurfaceId.IsNull())
  1293 	{
  1417 	{
  1294 		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 );
  1295 		iWsSession.UnregisterSurface(0, aSurfaceId);
  1419 		iWsSession.UnregisterSurface(0, iSurfaceId);
  1296 		iSurfaceHandler->DestroySurface(aSurfaceId);
  1420 		iSurfaceHandler->DestroySurface(aSurfaceId);
  1297 	}
  1421 	}
  1298 		
  1422 		
  1299 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL() --"), this);
  1423 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL() --"), this);
  1300 }
  1424 }
  1686     TInt resp = EPostIt;
  1810     TInt resp = EPostIt;
  1687     // Frame presentation time
  1811     // Frame presentation time
  1688     TInt64 uPresTime = frame->iTimestamp.Int64();
  1812     TInt64 uPresTime = frame->iTimestamp.Int64();
  1689       
  1813       
  1690     // 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
  1691     if((iCurrentPlaybackPosition.Int64() >= uPresTime) && (iPlayRate > 0))    
  1815     if((iCurrentPlaybackPosition.Int64() > uPresTime) && (iPlayRate > 0))    
  1692     {      
  1816     {      
  1693          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);
  1694          resp = ESkipIt;  //drop      
  1818          resp = ESkipIt;  //drop      
  1695     }      // 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
  1696     else if((iCurrentPlaybackPosition.Int64() <= uPresTime) && (iPlayRate < 0))    
  1820     else if((iCurrentPlaybackPosition.Int64() < uPresTime) && (iPlayRate < 0))    
  1697     {      
  1821     {      
  1698         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);
  1699         resp = ESkipIt;  //drop      
  1823         resp = ESkipIt;  //drop      
  1700     }
  1824     }
  1701     else if (iClockSource)
  1825     else if (iClockSource)
  1714             resp = ESkipIt;  //drop
  1838             resp = ESkipIt;  //drop
  1715         }
  1839         }
  1716        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);
  1717     }       
  1841     }       
  1718    
  1842    
  1719    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost -- %d"), this, resp);
  1843    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost -- %d BufID = %d"), this, resp, GetID(frame));
  1720     return resp;
  1844     return resp;
  1721 }
  1845 }
  1722 
  1846 
  1723 void CNGAPostProcHwDevice::ReleaseInputQ()
  1847 void CNGAPostProcHwDevice::ReleaseInputQ()
  1724 {
  1848 {
  2045 	if(iColorConversionQ.Count())
  2169 	if(iColorConversionQ.Count())
  2046     {
  2170     {
  2047 	    pOutPicture    = iColorConversionQ[0];
  2171 	    pOutPicture    = iColorConversionQ[0];
  2048 	    iColorConversionQ.Remove(0);
  2172 	    iColorConversionQ.Remove(0);
  2049 	    ConvertPostProcBuffer(aPicture, pOutPicture);
  2173 	    ConvertPostProcBuffer(aPicture, pOutPicture);
       
  2174 	   	pOutPicture->iTimestamp = aPicture->iTimestamp;
  2050 	    ReleasePicture(aPicture);    	    
  2175 	    ReleasePicture(aPicture);    	    
  2051     }				    
  2176     }				    
  2052     else
  2177     else
  2053     {
  2178     {
  2054        PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: color conversion"), this);
  2179        PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: color conversion"), this);
  2132    }
  2257    }
  2133    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints. err = %d --"), this,err);
  2258    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints. err = %d --"), this,err);
  2134    return err;
  2259    return err;
  2135 }
  2260 }
  2136 
  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 
  2137 CNGAPostProcTimer::CNGAPostProcTimer( CNGAPostProcHwDevice& aParent )
  2366 CNGAPostProcTimer::CNGAPostProcTimer( CNGAPostProcHwDevice& aParent )
  2138 :CTimer(EPriorityHigh),iParent(aParent)
  2367 :CTimer(EPriorityHigh),iParent(aParent)
  2139 {
  2368 {
  2140 	CActiveScheduler::Add(this);
  2369 	CActiveScheduler::Add(this);
  2141 }
  2370 }