--- a/mdfdevvideoextensions/nga_mdf_postprocessor/src/NGAPostProcHwDevice.cpp Tue May 25 14:20:15 2010 +0300
+++ b/mdfdevvideoextensions/nga_mdf_postprocessor/src/NGAPostProcHwDevice.cpp Wed Jun 09 11:20:54 2010 +0300
@@ -107,6 +107,8 @@
iVideoSurfaceObserver(NULL),
iVPObserver(NULL),
iPicSize(0,0),
+ iAspectRatioNum(1),
+ iAspectRatioDenom(1),
iStepFrameCount(0),
iPlayRate(KDefPlayRate),
iKeyFrameMode(EFalse),
@@ -180,7 +182,12 @@
if(!iSurfaceId.IsNull())
{
PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::UnregisterSurface"), this);
- iWsSession.UnregisterSurface(0, iSurfaceId);
+ TInt numScreens = iWsSession.NumberOfScreens();
+ for(TInt i=0;i < numScreens;i++)
+ {
+ iWsSession.UnregisterSurface(i, iSurfaceId);
+ }
+ iWsSession.Flush();
iSurfaceHandler->DestroySurface(iSurfaceId);
}
delete iSurfaceHandler;
@@ -1414,10 +1421,12 @@
{
aCropRect.Intersection( iPicSize);
}
- aPixelAspectRatio = TVideoAspectRatio(1,1);
- PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL()-- \
- cropRectWidth = %d cropRectHeight = %d --"), this, aCropRect.Width(), aCropRect.Height());
-
+ aPixelAspectRatio = TVideoAspectRatio(iAspectRatioNum,iAspectRatioDenom);
+ PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() \
+ cropRectWidth = %d cropRectHeight = %d"), this, aCropRect.Width(), aCropRect.Height());
+ PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() \
+ PAR Num = %d PAR Denom = %d"), this, aPixelAspectRatio.iNumerator, aPixelAspectRatio.iDenominator);
+ PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() --"), this);
}
void CNGAPostProcHwDevice::MmvssSurfaceRemovedL(const TSurfaceId& aSurfaceId)
@@ -1426,10 +1435,20 @@
if(!aSurfaceId.IsNull())
{
PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL(): UnregisterSurface ID = 0x%x"), this, aSurfaceId );
- iWsSession.UnregisterSurface(0, aSurfaceId);
+ TInt numScreens = iWsSession.NumberOfScreens();
+ for(TInt i=0;i < numScreens;i++)
+ {
+ iWsSession.UnregisterSurface(i, aSurfaceId);
+ }
+ iWsSession.Flush();
iSurfaceHandler->DestroySurface(aSurfaceId);
+ if(iSurfaceId == aSurfaceId)
+ {
+ iSurfaceCreatedEventPublished = EFalse;
+ iSurfaceId = TSurfaceId::CreateNullId();
+ iChunk.Close();
+ }
}
-
PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL() --"), this);
}
@@ -1441,7 +1460,9 @@
PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties PAR \
iAspectRatioNum = %d, iAspectRatioDenom = %d"), this,
aYuvFormat.iAspectRatioNum,aYuvFormat.iAspectRatioDenom);
- iPicSize = aPictureSize;
+ iPicSize = aPictureSize;
+ iAspectRatioNum = aYuvFormat.iAspectRatioNum;
+ iAspectRatioDenom = aYuvFormat.iAspectRatioDenom;
PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties Picture Size \
iWidth = %d, iHeight = %d, iSurfaceCreatedEventPublished = %d"),
this, iPicSize.iWidth,iPicSize.iHeight, iSurfaceCreatedEventPublished?1:0);
@@ -1523,22 +1544,13 @@
{
PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface ++"), this);
- TSize surfaceSize;
TUint8* lPtr;
TInt offset;
- if(iPicSize.iWidth > iPicSize.iHeight)
- {
- surfaceSize.iWidth = iPicSize.iWidth;
- surfaceSize.iHeight = iPicSize.iWidth;
- }
- else
- {
- surfaceSize.iWidth = iPicSize.iHeight;
- surfaceSize.iHeight = iPicSize.iHeight;
- }
+
+ PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface -- Creating %d x %d surface"), this, iPicSize.iWidth, iPicSize.iHeight);
TInt err = KErrNone;
- SetSurfaceAttributes(surfaceSize, 1);
+ SetSurfaceAttributes(iPicSize, 1);
err = iSurfaceHandler->CreateSurface(iAttributes, iSurfaceId);
if (err != KErrNone)
@@ -1548,6 +1560,36 @@
iProxy->MdvppFatalError(this, err);
return;
}
+
+ err = iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo);
+ if (err != KErrNone)
+ {
+ PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to get Surface info %d"),
+ this, err);
+ iSurfaceHandler->DestroySurface(iSurfaceId);
+ iSurfaceId = TSurfaceId::CreateNullId();
+ iProxy->MdvppFatalError(this, err);
+ return;
+ }
+
+ PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface() \
+ surfaceWidth = %d surfaceHeight = %d surfaceStride = %d"), this, iInfo().iSize.iWidth, iInfo().iSize.iHeight, iInfo().iStride);
+
+ TInt redrawBufferSize = aRedrawBuffer.Size();
+ TInt surfaceSize = iInfo().iStride * iInfo().iSize.iHeight;
+
+ PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface RedrawBuffer size= %d Surface size = %d"), this, redrawBufferSize, surfaceSize);
+
+ // Check whether redraw buffer will fit onto the surface.
+ // If this check fails then we won't raise a fatal error - We just won't create the redraw surface
+ if (redrawBufferSize > surfaceSize)
+ {
+ PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface Redraw buffer size larger than surface size"), this);
+ iSurfaceHandler->DestroySurface(iSurfaceId);
+ iSurfaceId = TSurfaceId::CreateNullId();
+ return;
+ }
+
err = iSurfaceHandler->MapSurface(iSurfaceId, iChunk);
if (err != KErrNone)
{
@@ -1558,19 +1600,6 @@
iProxy->MdvppFatalError(this, err);
return;
}
- err = iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo);
- if (err != KErrNone)
- {
- PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to get Surface info %d"),
- this, err);
- iSurfaceHandler->DestroySurface(iSurfaceId);
- iSurfaceId = TSurfaceId::CreateNullId();
- iChunk.Close();
- iProxy->MdvppFatalError(this, err);
- return;
- }
- PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface() \
- surfaceWidth = %d surfaceHeight = %d --"), this, iInfo().iSize.iWidth, iInfo().iSize.iHeight);
if((err = iSurfaceHandler->GetBufferOffset(iSurfaceId, 0, offset)) != KErrNone)
{
@@ -1581,18 +1610,23 @@
iProxy->MdvppFatalError(this, err);
return;
}
- PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface offset = %d aRedrawBuffer.Size()= %d --"), this, offset, aRedrawBuffer.Size());
-
+
+ PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface offset = %d"), this, offset);
+
lPtr = reinterpret_cast<TUint8*>(iChunk.Base() + offset);
- memcpy((TAny *)lPtr, (TAny *)aRedrawBuffer.Ptr(), aRedrawBuffer.Size());
+ memcpy((TAny *)lPtr, (TAny *)aRedrawBuffer.Ptr(), redrawBufferSize);
iRedrawSurfaceInUse = ETrue;
+ PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface(): New surface = 0x%x"), this, iSurfaceId);
+
PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface error = %d --"), this, err);
}
TInt CNGAPostProcHwDevice::SetupExternalSurface(const TSurfaceId &aSurfaceID)
{
+ PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface(): aSurfaceID = 0x%x"), this, aSurfaceID );
+
TInt err = KErrNone;
if(!iSurfaceId.IsNull())
@@ -1607,7 +1641,12 @@
{
// We never told the client about the surface, so we must destroy it ourselves
PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface - Destroying old surface"), this);
- iWsSession.UnregisterSurface(0, iSurfaceId);
+ TInt numScreens = iWsSession.NumberOfScreens();
+ for(TInt i=0;i < numScreens;i++)
+ {
+ iWsSession.UnregisterSurface(i, iSurfaceId);
+ }
+ iWsSession.Flush();
iSurfaceHandler->DestroySurface(iSurfaceId);
}
@@ -2060,7 +2099,13 @@
TInt CNGAPostProcHwDevice::RegisterSurface(const TSurfaceId& aSurfaceId)
{
PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:RegisterSurface(): RegisterSurface ID = 0x%x"), this, aSurfaceId);
- return(iWsSession.RegisterSurface(0, aSurfaceId));
+ TInt err = KErrNone;
+ TInt numScreens = iWsSession.NumberOfScreens();
+ for(TInt i=0; (i < numScreens && err == KErrNone); i++)
+ {
+ err = iWsSession.RegisterSurface(i, aSurfaceId);
+ }
+ return(err);
}
TInt CNGAPostProcHwDevice::IsGceReady()
@@ -2291,6 +2336,16 @@
err = iSurfaceHandler->SetSurfaceHint(iSurfaceId,iHint);
}
PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints. err = %d --"), this,err);
+ iHint.iKey.iUid = surfaceHints::KSurfaceContent;
+ iHint.iValue = surfaceHints::EVideoPlayback;
+ iHint.iMutable = ETrue;
+ err = iSurfaceHandler->AddSurfaceHint(iSurfaceId,iHint);
+ if(err == KErrAlreadyExists)
+ {
+ err = KErrNone;
+ err = iSurfaceHandler->SetSurfaceHint(iSurfaceId,iHint);
+ }
+ PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints. err = %d --"), this,err);
return err;
}