mdfdevvideoextensions/nga_mdf_postprocessor/src/NGAPostProcHwDevice.cpp
branchRCL_3
changeset 11 d5f04de580b7
parent 8 bc06d8566074
child 12 b74061f7f3d2
equal deleted inserted replaced
8:bc06d8566074 11:d5f04de580b7
   360     {
   360     {
   361 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: Invalid argument"), this);
   361 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: Invalid argument"), this);
   362 		User::Leave(KErrArgument);
   362 		User::Leave(KErrArgument);
   363 	}
   363 	}
   364 	pic = aPicture;	
   364 	pic = aPicture;	
   365 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePicture bufId = %d"), this,GetID(pic));
   365     if (iInputQ.Count() > 0)
   366 	iPictureCounters.iTotalPictures++;
   366     {
   367 	TInt64 delta = 0;
   367         AddToQ(pic);
   368 	TTimeToPost iTimeToPost = (TTimeToPost)IsTimeToPost(pic, delta);
   368         AttemptToPost();
   369 	if(!IsGceReady())
   369     }
   370     {  
   370     else
   371 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL GCE not ready"), this );
   371     {
   372 		if(iTimeToPost == EPostIt)
   372 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePicture bufId = %d"), this,GetID(pic));
       
   373 		iPictureCounters.iTotalPictures++;
       
   374 		TInt64 delta = 0;
       
   375 		TTimeToPost iTimeToPost = (TTimeToPost)IsTimeToPost(pic, delta);
       
   376 		if(!IsGceReady())
       
   377 	    {  
       
   378 			PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL GCE not ready"), this );
       
   379 			if(iTimeToPost == EPostIt)
       
   380 			{
       
   381 					iTimeToPost = EDelayIt;
       
   382 			}
       
   383 	    }
       
   384 	    if (delta > 0x7FFFFFFF)
       
   385 	    {
       
   386 	         PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL Too large delta .. skipping"), this ); 
       
   387 	         iTimeToPost = ESkipIt;
       
   388 	    }
       
   389 	
       
   390 		switch(iTimeToPost)
   373 		{
   391 		{
   374 				iTimeToPost = EDelayIt;
   392 			case EDelayIt:
       
   393 			{
       
   394 				if(AddToQ(pic) != 0)
       
   395 				{
       
   396 					break;
       
   397 				}
       
   398 				iPostingTimer->Cancel();
       
   399 				SetTimer(delta);
       
   400 			}
       
   401 			break;
       
   402 			case EPostIt:
       
   403 			{
       
   404 		
       
   405 				if(iIsColorConversionNeeded)
       
   406 				{
       
   407 					TVideoPicture* ccPic;				
       
   408 	    			ccPic = DoColorConvert(pic); // output will be in ccPic
       
   409 	    			pic = ccPic;			   
       
   410 				}
       
   411 				iProcessQ.Append(pic);
       
   412 						
       
   413 				#ifdef _DUMP_YUV_FRAMES
       
   414 				captureYuv(pic);
       
   415 				#endif
       
   416 				iSessionManager->PostPicture(iSurfaceId, GetID(pic), iInfo().iBuffers, ETrue);	
       
   417 				iCurrentPlaybackPosition = pic->iTimestamp;			
       
   418 			
       
   419 				if(!iFirstPictureUpdated)
       
   420 				{
       
   421 					iFirstPictureUpdated = ETrue;
       
   422 					PublishSurfaceCreated();
       
   423 				}
       
   424 			}
       
   425 			break;
       
   426 			case ESkipIt:
       
   427 			{
       
   428 				ReleasePicture(pic); 
       
   429 				PicturesSkipped();
       
   430 			}
       
   431 			break;
   375 		}
   432 		}
   376     }
   433     }
   377 	switch(iTimeToPost)
       
   378 	{
       
   379 		case EDelayIt:
       
   380 		{
       
   381 			if(AddToQ(pic) != 0)
       
   382 			{
       
   383 				break;
       
   384 			}
       
   385 			iPostingTimer->Cancel();
       
   386 			SetTimer(delta);
       
   387 		}
       
   388 		break;
       
   389 		case EPostIt:
       
   390 		{
       
   391 		
       
   392 			if(iIsColorConversionNeeded)
       
   393 			{
       
   394 				TVideoPicture* ccPic;				
       
   395     			ccPic = DoColorConvert(pic); // output will be in ccPic
       
   396     			pic = ccPic;			   
       
   397 			}
       
   398 			iProcessQ.Append(pic);
       
   399 						
       
   400 			#ifdef _DUMP_YUV_FRAMES
       
   401 			captureYuv(pic);
       
   402 			#endif
       
   403 			iSessionManager->PostPicture(iSurfaceId, GetID(pic), iInfo().iBuffers, ETrue);	
       
   404 			iCurrentPlaybackPosition = pic->iTimestamp;			
       
   405 			
       
   406 			if(!iFirstPictureUpdated)
       
   407 			{
       
   408 				iFirstPictureUpdated = ETrue;
       
   409 				PublishSurfaceCreated();
       
   410 			}
       
   411 		}
       
   412 		break;
       
   413 		case ESkipIt:
       
   414 		{
       
   415 			ReleasePicture(pic); 
       
   416 			PicturesSkipped();
       
   417 		}
       
   418 		break;
       
   419 	}
       
   420 
       
   421 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePicture --"), this);
   434 	PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePicture --"), this);
   422 }
   435 }
   423 
   436 
   424 
   437 
   425 CPostProcessorInfo* 
   438 CPostProcessorInfo* 
  1572 }
  1585 }
  1573 
  1586 
  1574 TInt CNGAPostProcHwDevice::AttemptToPost()
  1587 TInt CNGAPostProcHwDevice::AttemptToPost()
  1575 {
  1588 {
  1576    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AttemptToPost ++ Q:%d"), this, iInputQ.Count());
  1589    PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AttemptToPost ++ Q:%d"), this, iInputQ.Count());
       
  1590    if (iPPState == EPaused)
       
  1591    {
       
  1592         return KErrNone;
       
  1593    }
       
  1594 
  1577     TInt err = KErrNotReady;
  1595     TInt err = KErrNotReady;
  1578     TInt count = iInputQ.Count();
  1596     TInt count = iInputQ.Count();
  1579     TBool bDone = EFalse;
  1597     TBool bDone = EFalse;
  1580     TVideoPicture* pic = PeekQ();   		
  1598     TVideoPicture* pic = PeekQ();   		
  1581   	while(pic && !bDone)
  1599   	while(pic && !bDone)
  1644 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost FAILED: Invalid frame ptr."), this);
  1662 		PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost FAILED: Invalid frame ptr."), this);
  1645 		return KErrGeneral;
  1663 		return KErrGeneral;
  1646 	}
  1664 	}
  1647 
  1665 
  1648     TInt resp = EPostIt;
  1666     TInt resp = EPostIt;
  1649     
  1667     // Frame presentation time
  1650     if (iClockSource)
  1668     TInt64 uPresTime = frame->iTimestamp.Int64();
  1651     {
  1669       
  1652         // Frame presentation time
  1670     // Check if this is an out of order frame in case of forward playback
  1653         TInt64 uPresTime = frame->iTimestamp.Int64();
  1671     if((iCurrentPlaybackPosition.Int64() >= uPresTime) && (iPlayRate > 0))    
       
  1672     {      
       
  1673          PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost : Out of order frame (forward playback) Tfm=%d"), this,(TInt)uPresTime);
       
  1674          resp = ESkipIt;  //drop      
       
  1675     }      // Check if this is an out of order frame in case of backward playback
       
  1676     else if((iCurrentPlaybackPosition.Int64() <= uPresTime) && (iPlayRate < 0))    
       
  1677     {      
       
  1678         PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost : Out of order frame (backward playback) Tfm=%d"), this,(TInt)uPresTime);
       
  1679         resp = ESkipIt;  //drop      
       
  1680     }
       
  1681     else if (iClockSource)
       
  1682     {
  1654         // The time to sync with.
  1683         // The time to sync with.
  1655         TInt64 uSyncTime = iClockSource->Time().Int64();
  1684         TInt64 uSyncTime = iClockSource->Time().Int64();
  1656         
  1685         
  1657         delta = uPresTime - uSyncTime;
  1686         delta = uPresTime - uSyncTime;
  1658         if (( delta > KRenderAhead ) &&  (iPlayRate > 0))	// Delay condition not checked for 
  1687         if (( delta > KRenderAhead ) &&  (iPlayRate > 0))	// Delay condition not checked for