1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mdfdevvideoextensions/nga_mdf_postprocessor/src/NGAPostProcHwDevice.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,2504 @@
1.4 +/*
1.5 +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include "NGAPostProcHwDevice.h"
1.23 +#include "NGAPostProcSessionManager.h"
1.24 +#include "NGAPostProcSurfaceHandler.h"
1.25 +
1.26 +// post-processor info
1.27 +const TUid KUidVideoPostProcHwDevice = {KUidNGAPostProcHwDeviceImplUid};
1.28 +_LIT(KManufacturer, "Nokia Inc.");
1.29 +_LIT(KIdentifier, "Nokia S60 Video Post Processor Hardware Device Plugin");
1.30 +
1.31 +// --- Constants ---
1.32 +const TInt KMaxVBMBuffers = 4;
1.33 +const TInt KMinVBMInputWidth = 32;
1.34 +const TInt KMinVBMInputHeight = 32;
1.35 +const TInt KMaxVBMInputWidth = 1280;
1.36 +const TInt KMaxVBMInputHeight = 720;
1.37 +const TInt KRenderAhead = 50000;
1.38 +const TInt KMaxRenderDelay = 50000;
1.39 +const TInt KPostingOfset = 0;
1.40 +const TInt KColorConversionBuffers = 3;
1.41 +const TInt KMaxBuffersGceCanHold = 3;
1.42 +const TInt KDefPlayRate = 100;
1.43 +const TInt KMaxAllowedSkipInNFrames = 40;
1.44 +#ifdef __cplusplus
1.45 +extern "C"
1.46 +{
1.47 +#endif
1.48 +
1.49 +int32 gColorConvYUVtoYUV422Int (tBaseVideoFrame *yuv420Frame, tBaseVideoFrame* yuv422Frame,
1.50 + uint8 outClrFmt, int16 stride);
1.51 +
1.52 +int32 Emz_VDec_gColorConv_YUVtoRGB (
1.53 + tBaseVideoFrame *srcImage, uint8 *dstImage, tWndParam *srcWindow,
1.54 + tWndParam *dstWindow, uint8 srcImageFormat, uint8 dstImageFormat,
1.55 + uint8 colorConvScheme);
1.56 +
1.57 +#ifdef __cplusplus
1.58 +}
1.59 +#endif
1.60 +
1.61 +//**************************************************
1.62 +
1.63 +CMMFVideoPostProcHwDevice* CNGAPostProcHwDevice::NewL()
1.64 +{
1.65 + PP_DEBUG(_L("CNGAPostProcHwDevice::NewL() ++"));
1.66 +
1.67 + CNGAPostProcHwDevice* self = new (ELeave) CNGAPostProcHwDevice;
1.68 + CleanupStack::PushL(self);
1.69 + self->ConstructL();
1.70 + CleanupStack::Pop();
1.71 +
1.72 + PP_DEBUG(_L("CNGAPostProcHwDevice::NewL() --"));
1.73 + return (CMMFVideoPostProcHwDevice*)self;
1.74 +}
1.75 +
1.76 +void CNGAPostProcHwDevice::ConstructL()
1.77 +{
1.78 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::ConstructL() ++"), this);
1.79 +
1.80 + // support for VBM buffer interface
1.81 + iVBMBufferOptions.iNumInputBuffers = KMaxVBMBuffers;
1.82 + iVBMBufferOptions.iBufferSize = TSize(KMaxVBMInputWidth, KMaxVBMInputHeight);
1.83 + iPostingTimer = CNGAPostProcTimer::NewL(*this);
1.84 + iWsSession.Connect();
1.85 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::ConstructL() --"), this);
1.86 +}
1.87 +
1.88 +CNGAPostProcHwDevice::CNGAPostProcHwDevice()
1.89 + : iProxy(NULL),
1.90 + iInputDecoderDevice(NULL),
1.91 + iCurrentPlaybackPosition(TTimeIntervalMicroSeconds(0)),
1.92 + iPPState(EInitializing),
1.93 + iSurfaceHandler(NULL),
1.94 + iSessionManager(NULL),
1.95 + iIsInputEnded(EFalse),
1.96 + iPostingTimer(NULL),
1.97 + iFirstPictureUpdated(EFalse),
1.98 + iUsingExternalSurface(EFalse),
1.99 + iIsColorConversionNeeded(EFalse),
1.100 + iSurfaceCreatedEventPublished(EFalse),
1.101 + iOverflowPictureCounter(0),
1.102 + iVideoFrameBufSize(0),
1.103 + iResourceLost(EFalse),
1.104 + iRedrawDone(EFalse),
1.105 + iRedrawSurfaceInUse(EFalse),
1.106 + iVBMObserver(NULL),
1.107 + count(0),
1.108 + iSurfaceMask(surfaceHints::EAllowAllExternals),
1.109 + iSurfaceKey(TUid::Uid(surfaceHints::KSurfaceProtection)),
1.110 + iVideoSurfaceObserver(NULL),
1.111 + iVPObserver(NULL),
1.112 + iPicSize(0,0),
1.113 + iAspectRatioNum(1),
1.114 + iAspectRatioDenom(1),
1.115 + iStepFrameCount(0),
1.116 + iPlayRate(KDefPlayRate),
1.117 + iKeyFrameMode(EFalse),
1.118 + iFPObserver(NULL)
1.119 +{
1.120 + iSurfaceId = TSurfaceId::CreateNullId();
1.121 + iAttributes().iPixelFormat = EUidPixelFormatYUV_422Interleaved;
1.122 +}
1.123 +
1.124 +CNGAPostProcHwDevice::~CNGAPostProcHwDevice()
1.125 +{
1.126 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::~CNGAPostProcHwDevice() ++"), this);
1.127 + if (iSessionManager)
1.128 + {
1.129 + iSessionManager->CancelUpdate();
1.130 + delete iSessionManager;
1.131 + iSessionManager = NULL;
1.132 + }
1.133 +
1.134 + while (iSupportedInputFormats.Count()>0)
1.135 + {
1.136 + iSupportedInputFormats.Remove(0);
1.137 + }
1.138 +
1.139 + while (iProcessQ.Count()>0)
1.140 + {
1.141 + iProcessQ.Remove(0);
1.142 + }
1.143 +
1.144 + if(iPostingTimer)
1.145 + {
1.146 + iPostingTimer->Cancel();
1.147 + delete iPostingTimer;
1.148 + iPostingTimer = NULL;
1.149 + }
1.150 +
1.151 + while (iVBMBufferReferenceQ.Count()>0)
1.152 + {
1.153 + TVideoPicture* pic = iVBMBufferReferenceQ[0];
1.154 + iVBMBufferReferenceQ.Remove(0);
1.155 + if (iColorConversionQ.Count()>0)
1.156 + {
1.157 + iColorConversionQ.Remove(0);
1.158 + }
1.159 +
1.160 + if (pic->iHeader) delete pic->iHeader;
1.161 + delete pic->iData.iRawData;
1.162 + delete pic;
1.163 + }
1.164 +
1.165 + iSupportedInputFormats.Reset();
1.166 + iSupportedInputFormats.Close();
1.167 +
1.168 + iVBMBufferReferenceQ.Reset();
1.169 + iVBMBufferReferenceQ.Close();
1.170 +
1.171 + iColorConversionQ.Reset();
1.172 + iColorConversionQ.Close();
1.173 +
1.174 + iVBMBufferQ.Reset();
1.175 + iVBMBufferQ.Close();
1.176 +
1.177 + iProcessQ.Reset();
1.178 + iProcessQ.Close();
1.179 +
1.180 + iInputQ.Reset();
1.181 + iInputQ.Close();
1.182 +
1.183 + if (iSurfaceHandler)
1.184 + {
1.185 + if(!iSurfaceId.IsNull())
1.186 + {
1.187 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::UnregisterSurface"), this);
1.188 + TInt numScreens = iWsSession.NumberOfScreens();
1.189 + for(TInt i=0;i < numScreens;i++)
1.190 + {
1.191 + iWsSession.UnregisterSurface(i, iSurfaceId);
1.192 + }
1.193 + iWsSession.Flush();
1.194 + iSurfaceHandler->DestroySurface(iSurfaceId);
1.195 + }
1.196 + delete iSurfaceHandler;
1.197 + iSurfaceHandler = NULL;
1.198 + }
1.199 +
1.200 + iWsSession.Close();
1.201 + iChunk.Close();
1.202 + RDebug::Printf("------ Statistics of Post Processor ------");
1.203 + RDebug::Printf(" Pictures Received : %d", iPictureCounters.iTotalPictures);
1.204 + RDebug::Printf(" Pictures Displayed: %d", iPictureCounters.iPicturesDisplayed);
1.205 + RDebug::Printf(" Pictures Skipped : %d", iPictureCounters.iPicturesSkipped);
1.206 + RDebug::Printf(" Pictures overflow : %d", iOverflowPictureCounter);
1.207 + RDebug::Printf("------------------------------------------");
1.208 +
1.209 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:~() --"), this);
1.210 +}
1.211 +
1.212 +void CNGAPostProcHwDevice::SetInputFormatL(const TUncompressedVideoFormat& aFormat)
1.213 +{
1.214 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputFormatL() Pattern= %x ++"), this, aFormat.iYuvFormat.iPattern);
1.215 + if (iPPState != EInitializing)
1.216 + {
1.217 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputFormatL() FAILED: Unexpected state"), this);
1.218 + User::Leave(KErrNotReady);
1.219 + }
1.220 +
1.221 + iVideoFormat = aFormat;
1.222 + if( ((iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma1) ||
1.223 + (iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma2) ||
1.224 + (iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma3) ))
1.225 + {
1.226 + iVideoFormat.iYuvFormat.iCoefficients = EYuvBt709Range1;
1.227 + iVideoFormat.iYuvFormat.iPattern = EYuv422Chroma1;
1.228 + iVideoFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedBE;
1.229 +
1.230 +#if defined __WINSCW__
1.231 + iIsColorConversionNeeded = ETrue;
1.232 +#else
1.233 + iAttributes().iPixelFormat = EUidPixelFormatYUV_420Planar;
1.234 +#endif //__WINSCW__
1.235 + }
1.236 +
1.237 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputFormatL() WARNING: -- Not Found!"), this);
1.238 +}
1.239 +
1.240 +
1.241 +void CNGAPostProcHwDevice::SetInputDevice(CMMFVideoDecodeHwDevice* aDevice)
1.242 +{
1.243 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputDevice() ++"), this);
1.244 +
1.245 + if (iPPState != EInitializing)
1.246 + {
1.247 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputDevice() FAILED: unexpected state"), this);
1.248 + return;
1.249 + }
1.250 +
1.251 + iInputDecoderDevice = aDevice;
1.252 +
1.253 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputDevice() --"), this);
1.254 +}
1.255 +
1.256 +void CNGAPostProcHwDevice::GetOutputFormatListL(RArray<TUncompressedVideoFormat>& )
1.257 +{
1.258 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetOutputFormatListL() ++"), this);
1.259 +
1.260 +
1.261 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetOutputFormatListL() --"), this);
1.262 +}
1.263 +
1.264 +void CNGAPostProcHwDevice::SetOutputFormatL(const TUncompressedVideoFormat& )
1.265 +{
1.266 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetOutputFormatL() ++"), this);
1.267 +
1.268 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetOutputFormatL() --"), this);
1.269 +}
1.270 +
1.271 +void CNGAPostProcHwDevice::SetClockSource(MMMFClockSource* aClock)
1.272 +{
1.273 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetClockSource() ++"), this);
1.274 +
1.275 + if (iPPState != EInitializing)
1.276 + {
1.277 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetClockSource() FAILED: Unexpected state"), this);
1.278 + return;
1.279 + }
1.280 + iClockSource = aClock;
1.281 +
1.282 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetClockSource() --"), this);
1.283 +}
1.284 +
1.285 +void CNGAPostProcHwDevice::SetVideoDestScreenL(TBool /*aScreen*/)
1.286 +{
1.287 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetVideoDestScreenL() ++"), this);
1.288 +
1.289 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetVideoDestScreenL() --"), this);
1.290 +}
1.291 +
1.292 +void CNGAPostProcHwDevice::SetProxy(MMMFDevVideoPlayProxy& aProxy)
1.293 +{
1.294 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetProxy() ++"), this);
1.295 +
1.296 + if (iPPState != EInitializing)
1.297 + {
1.298 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetProxy() FAILED: Unexpected state"), this);
1.299 + return;
1.300 + }
1.301 +
1.302 + iProxy = &aProxy;
1.303 +
1.304 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetProxy() --"), this);
1.305 +}
1.306 +
1.307 +void CNGAPostProcHwDevice::Initialize()
1.308 +{
1.309 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize ++"));
1.310 + TInt err = KErrNone;
1.311 +
1.312 + if (iPPState != EInitializing)
1.313 + {
1.314 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize() FAILED: Unexpected state"), this);
1.315 + return;
1.316 + }
1.317 + if (!iSurfaceHandler)
1.318 + {
1.319 + TRAP(err, iSurfaceHandler = CNGAPostProcSurfaceHandler::NewL());
1.320 + if (err != KErrNone)
1.321 + {
1.322 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create SurfaceHandler."), this);
1.323 + return;
1.324 + }
1.325 + }
1.326 + if (!iSessionManager)
1.327 + {
1.328 + TRAP(err, iSessionManager = CNGAPostProcSessionManager::NewL());
1.329 + if (err != KErrNone)
1.330 + {
1.331 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create SessionManager."), this);
1.332 + return;
1.333 + }
1.334 + iSessionManager->SetObserver(*this);
1.335 + }
1.336 +
1.337 + if (iInputDecoderDevice)
1.338 + {
1.339 + MMmfVideoResourceHandler* handler = NULL;
1.340 + handler = (MMmfVideoResourceHandler*)iInputDecoderDevice->CustomInterface(KUidMmfVideoResourceManagement);
1.341 + if (handler)
1.342 + {
1.343 + handler->MmvrhSetObserver((MMmfVideoResourceObserver*)this);
1.344 + }
1.345 + else
1.346 + {
1.347 + PP_DEBUG(_L("ppHwDev[%x]:Initialize() decoder yet to implement MMmfVideoResourceHandler CI"), this);
1.348 + }
1.349 +
1.350 + MMmfVideoPropertiesNotifier* VPHandler = NULL;
1.351 + VPHandler = (MMmfVideoPropertiesNotifier*)iInputDecoderDevice->CustomInterface(KUidMmfVideoPropertiesManagement);
1.352 + if (VPHandler)
1.353 + {
1.354 + PP_DEBUG(_L("ppHwDev[%x]:Initialize() Register for video property changes"), this);
1.355 + VPHandler->MmvpnSetObserver((MMmfVideoPropertiesObserver*)this);
1.356 + }
1.357 + else
1.358 + {
1.359 + PP_DEBUG(_L("ppHwDev[%x]:Initialize() decoder yet to implement MMmfVideoPropertiesNotifier CI"), this);
1.360 + }
1.361 + }
1.362 +
1.363 + // Initialize picture counters
1.364 + iPictureCounters.iPicturesSkipped = 0;
1.365 + iPictureCounters.iPicturesDisplayed = 0;
1.366 + iPictureCounters.iTotalPictures = 0;
1.367 + iOverflowPictureCounter = 0;
1.368 + if (iProxy)
1.369 + {
1.370 + iProxy->MdvppInitializeComplete(this, err);
1.371 + }
1.372 + iPPState = EInitialized;
1.373 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize --"), this);
1.374 +}
1.375 +
1.376 +void CNGAPostProcHwDevice::WritePictureL(TVideoPicture* aPicture)
1.377 +{
1.378 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePicture bufId = %d"), this,GetID(aPicture));
1.379 + TVideoPicture* pic;
1.380 + if (iPPState==EInitializing || iPPState==EStopped || iIsInputEnded)
1.381 + {
1.382 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: Unexpected state"), this);
1.383 + User::Leave(KErrNotReady);
1.384 + }
1.385 +
1.386 + if(!aPicture)
1.387 + {
1.388 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: Invalid argument"), this);
1.389 + User::Leave(KErrArgument);
1.390 + }
1.391 + pic = aPicture;
1.392 + iPictureCounters.iTotalPictures++;
1.393 + if((iPPState != EPlaying) && (iFirstPictureUpdated))
1.394 + {
1.395 + AddToQ(pic);
1.396 + }
1.397 + else if( iInputQ.Count() > 0 )
1.398 + {
1.399 + AddToQ(pic);
1.400 + AttemptToPost();
1.401 + }
1.402 + else
1.403 + {
1.404 + TInt64 delta = 0;
1.405 + TTimeToPost iTimeToPost = (TTimeToPost)IsTimeToPost(pic, delta);
1.406 + if(!IsGceReady())
1.407 + {
1.408 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL GCE not ready"), this );
1.409 + if(iTimeToPost == EPostIt)
1.410 + {
1.411 + iTimeToPost = EDelayIt;
1.412 + }
1.413 + }
1.414 + if (delta > 0x7FFFFFFF)
1.415 + {
1.416 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL Too large delta .. skipping"), this );
1.417 + iTimeToPost = ESkipIt;
1.418 + }
1.419 + if(!iFirstPictureUpdated)
1.420 + {
1.421 + if(iTimeToPost == EDelayIt)
1.422 + {
1.423 + iTimeToPost = EPostIt;
1.424 + }
1.425 + }
1.426 + switch(iTimeToPost)
1.427 + {
1.428 + case EDelayIt:
1.429 + {
1.430 + if(AddToQ(pic) != 0)
1.431 + {
1.432 + break;
1.433 + }
1.434 + iPostingTimer->Cancel();
1.435 + SetTimer(delta);
1.436 + }
1.437 + break;
1.438 + case EPostIt:
1.439 + {
1.440 +
1.441 + if(iIsColorConversionNeeded)
1.442 + {
1.443 + TVideoPicture* ccPic;
1.444 + ccPic = DoColorConvert(pic); // output will be in ccPic
1.445 + pic = ccPic;
1.446 + }
1.447 + iProcessQ.Append(pic);
1.448 +
1.449 + #ifdef _DUMP_YUV_FRAMES
1.450 + captureYuv(pic);
1.451 + #endif
1.452 + iSessionManager->PostPicture(iSurfaceId, GetID(pic), iInfo().iBuffers, ETrue);
1.453 + iCurrentPlaybackPosition = pic->iTimestamp;
1.454 +
1.455 + if(!iFirstPictureUpdated)
1.456 + {
1.457 + iFirstPictureUpdated = ETrue;
1.458 + if(!iSurfaceCreatedEventPublished)
1.459 + {
1.460 + PublishSurfaceCreated();
1.461 + }
1.462 + }
1.463 + }
1.464 + break;
1.465 + case ESkipIt:
1.466 + {
1.467 + ReleasePicture(pic);
1.468 + PicturesSkipped();
1.469 + }
1.470 + break;
1.471 + }
1.472 + }
1.473 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePicture --"), this);
1.474 +}
1.475 +
1.476 +
1.477 +CPostProcessorInfo*
1.478 +CNGAPostProcHwDevice::PostProcessorInfoLC()
1.479 +{
1.480 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PostProcessorInfoLC() ++"), this);
1.481 + TUncompressedVideoFormat yuvFormat;
1.482 + RArray<TUint32> SupportedPostProcess;
1.483 + TBool SupportedHwAcceleration = ETrue; //Non-Accelerated ETrue,
1.484 + TYuvToRgbCapabilities SupportedYuvToRgbCapab;
1.485 + TInt32 SupportedRotations = ERotateNone; // no rotation supported
1.486 +
1.487 + TBool SupportedArbitraryScaling = EFalse; // no scaling supported
1.488 + RArray<TScaleFactor> SupportedScaleFactors;
1.489 + TBool SupportedAntiAliasing = EFalse;
1.490 +
1.491 + //default
1.492 + yuvFormat.iDataFormat = EYuvRawData;
1.493 + yuvFormat.iYuvFormat.iYuv2RgbMatrix = 0;
1.494 + yuvFormat.iYuvFormat.iRgb2YuvMatrix = 0;
1.495 + yuvFormat.iYuvFormat.iAspectRatioNum = 1;
1.496 + yuvFormat.iYuvFormat.iAspectRatioDenom = 1;
1.497 + yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range1;
1.498 + yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1;
1.499 + yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedBE;
1.500 +
1.501 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.502 +
1.503 + yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2;
1.504 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.505 +
1.506 + yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range0;
1.507 + yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1;
1.508 + yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedBE;
1.509 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.510 +
1.511 + yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2;
1.512 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.513 +
1.514 + yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range0;
1.515 + yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1;
1.516 + yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedLE;
1.517 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.518 +
1.519 + yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2;
1.520 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.521 +
1.522 + yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range1;
1.523 + yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1;
1.524 + yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedLE;
1.525 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.526 +
1.527 + yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2;
1.528 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.529 +
1.530 + yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range0;
1.531 + yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1;
1.532 + yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedBE;
1.533 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.534 +
1.535 + yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2;
1.536 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.537 +
1.538 + yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range1;
1.539 + yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1;
1.540 + yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedBE;
1.541 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.542 +
1.543 + yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2;
1.544 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.545 +
1.546 + yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range0;
1.547 + yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1;
1.548 + yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedLE;
1.549 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.550 +
1.551 + yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2;
1.552 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.553 +
1.554 + yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range1;
1.555 + yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1;
1.556 + yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedLE;
1.557 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.558 +
1.559 + yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2;
1.560 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.561 +
1.562 + //YUV 420 planar
1.563 + yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range1;
1.564 + yuvFormat.iYuvFormat.iPattern = EYuv420Chroma1;
1.565 + yuvFormat.iYuvFormat.iDataLayout = EYuvDataPlanar;
1.566 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.567 +
1.568 + yuvFormat.iYuvFormat.iPattern = EYuv420Chroma2;
1.569 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.570 +
1.571 + yuvFormat.iYuvFormat.iPattern = EYuv420Chroma3;
1.572 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.573 +
1.574 + yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range0;
1.575 + yuvFormat.iYuvFormat.iPattern = EYuv420Chroma1;
1.576 + yuvFormat.iYuvFormat.iDataLayout = EYuvDataPlanar;
1.577 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.578 +
1.579 + yuvFormat.iYuvFormat.iPattern = EYuv420Chroma2;
1.580 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.581 +
1.582 + yuvFormat.iYuvFormat.iPattern = EYuv420Chroma3;
1.583 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.584 +
1.585 + yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range1;
1.586 + yuvFormat.iYuvFormat.iPattern = EYuv420Chroma1;
1.587 + yuvFormat.iYuvFormat.iDataLayout = EYuvDataPlanar;
1.588 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.589 +
1.590 + yuvFormat.iYuvFormat.iPattern = EYuv420Chroma2;
1.591 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.592 +
1.593 + yuvFormat.iYuvFormat.iPattern = EYuv420Chroma3;
1.594 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.595 +
1.596 + yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range0;
1.597 + yuvFormat.iYuvFormat.iPattern = EYuv420Chroma1;
1.598 + yuvFormat.iYuvFormat.iDataLayout = EYuvDataPlanar;
1.599 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.600 +
1.601 + yuvFormat.iYuvFormat.iPattern = EYuv420Chroma2;
1.602 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.603 +
1.604 + yuvFormat.iYuvFormat.iPattern = EYuv420Chroma3;
1.605 + User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
1.606 +
1.607 + CPostProcessorInfo* postProcessorInfo = CPostProcessorInfo::NewL(
1.608 + KUidVideoPostProcHwDevice,
1.609 + KManufacturer,
1.610 + KIdentifier,
1.611 + TVersion(1, 0, 0),
1.612 + iSupportedInputFormats.Array(),
1.613 + SupportedPostProcess.Array(),
1.614 + SupportedHwAcceleration,
1.615 + ETrue, //Direct Display
1.616 + SupportedYuvToRgbCapab,
1.617 + SupportedRotations,
1.618 + SupportedArbitraryScaling,
1.619 + SupportedScaleFactors.Array(),
1.620 + SupportedAntiAliasing);
1.621 +
1.622 + CleanupStack::PushL(postProcessorInfo);
1.623 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PostProcessorInfoLC() --"), this);
1.624 + return postProcessorInfo;
1.625 +}
1.626 +
1.627 +void CNGAPostProcHwDevice::MmvprcGetPlayRateCapabilitiesL(TVideoPlayRateCapabilities& aCap)
1.628 +{
1.629 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcGetPlayRateCapabilitiesL ++"), this);
1.630 + aCap.iPlayForward = ETrue;
1.631 + aCap.iPlayBackward = ETrue;
1.632 + aCap.iStepForward = ETrue;
1.633 + aCap.iStepBackward = ETrue;
1.634 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcGetPlayRateCapabilitiesL --"), this);
1.635 +}
1.636 +
1.637 +void CNGAPostProcHwDevice::MmvprcSetPlayRateL(const TInt aRate)
1.638 +{
1.639 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcSetPlayRateL ++"), this);
1.640 + iPlayRate = aRate;
1.641 + if (iPlayRate<0)
1.642 + {
1.643 + iKeyFrameMode = ETrue;
1.644 + }
1.645 + else
1.646 + {
1.647 + iKeyFrameMode = EFalse;
1.648 + ResetCountingBuffer();
1.649 + }
1.650 + //In fast forward go direct to key frame mode if speed >4X =
1.651 + if (iPlayRate>KDefPlayRate*4)
1.652 + {
1.653 + if (iFPObserver)
1.654 + {
1.655 + iFPObserver->MmvproKeyFrameModeRequest();
1.656 + iKeyFrameMode=ETrue;
1.657 + }
1.658 + }
1.659 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcSetPlayRateL=%d --"), this, aRate);
1.660 +}
1.661 +
1.662 +TInt CNGAPostProcHwDevice::MmvprcPlayRateL()
1.663 +{
1.664 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcPlayRateL= ++"), this);
1.665 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcPlayRateL= --"), this);
1.666 + return iPlayRate;
1.667 +}
1.668 +
1.669 +void CNGAPostProcHwDevice::MmvprcStepFrameL(const TInt aStep)
1.670 +{
1.671 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcStepFrameL= ++"), this);
1.672 + iStepFrameCount = aStep;
1.673 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcStepFrameL=%d --"), this, aStep);
1.674 +}
1.675 +
1.676 +void CNGAPostProcHwDevice::MmvprcSetObserver(MMmfVideoPlayRateObserver& aObserver)
1.677 +{
1.678 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcSetObserver ++"), this);
1.679 + iFPObserver = &aObserver;
1.680 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcSetObserver --"), this);
1.681 +}
1.682 +
1.683 +void CNGAPostProcHwDevice::MmvsoSetSecureOutputL(TBool aSecure)
1.684 +{
1.685 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvsoSetSecureOutputL aSecure = %d++"), this, aSecure);
1.686 + TInt err = KErrNone;
1.687 + if(aSecure)
1.688 + {
1.689 + iSurfaceMask = surfaceHints::EAllowInternalOnly;
1.690 + }
1.691 + else
1.692 + {
1.693 + iSurfaceMask = surfaceHints::EAllowAllExternals;
1.694 + }
1.695 + if(!iSurfaceId.IsNull())
1.696 + {
1.697 + err = AddHints();
1.698 + if(err != KErrNone)
1.699 + {
1.700 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvsoSetSecureOutputL -- leaving err = %d"), this, err);
1.701 + User::Leave(err);
1.702 + }
1.703 + }
1.704 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvsoSetSecureOutputL --"), this);
1.705 +}
1.706 +
1.707 +void CNGAPostProcHwDevice::MmavsoSetAllowedOutputL(TUint aAllowedOutputMask)
1.708 +{
1.709 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmavsoSetAllowedOutputL aAllowedOutputMask=0x%08x ++"), this,aAllowedOutputMask);
1.710 + TInt err = KErrNone;
1.711 + iSurfaceMask = surfaceHints::EAllowInternalOnly;
1.712 + if (aAllowedOutputMask == EVideoAllowAll)
1.713 + {
1.714 + iSurfaceMask = surfaceHints::EAllowAllExternals;
1.715 + }
1.716 + else if (aAllowedOutputMask == EVideoAllowInternalOnly)
1.717 + {
1.718 + iSurfaceMask = surfaceHints::EAllowInternalOnly;
1.719 + }
1.720 + else
1.721 + {
1.722 + // we hope to find some valid output prefs
1.723 + if (aAllowedOutputMask & EVideoAllowAnalog)
1.724 + {
1.725 + iSurfaceMask |= surfaceHints::EAllowAnalog;
1.726 + }
1.727 + if (aAllowedOutputMask & EVideoAllowMacroVision)
1.728 + {
1.729 + iSurfaceMask |= surfaceHints::EAllowAnalogProtectionRequired;
1.730 + }
1.731 + if (aAllowedOutputMask & EVideoAllowHDMI)
1.732 + {
1.733 + iSurfaceMask |= surfaceHints::EAllowDigital;
1.734 + }
1.735 + if (aAllowedOutputMask & EVideoAllowHdmiHdcpRequested)
1.736 + {
1.737 + iSurfaceMask |= surfaceHints::EAllowDigitalProtectionRequested;
1.738 + }
1.739 + if (aAllowedOutputMask & EVideoAllowHdmiHdcpRequired)
1.740 + {
1.741 + iSurfaceMask |= surfaceHints::EAllowDigitalProtectionRequired;
1.742 + }
1.743 + }
1.744 +
1.745 + if((!iSurfaceId.IsNull()))
1.746 + {
1.747 + err = AddHints();
1.748 + if(err != KErrNone)
1.749 + {
1.750 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmavsoSetAllowedOutputL -- leaving err = %d"), this, err);
1.751 + User::Leave(err);
1.752 + }
1.753 + }
1.754 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmavsoSetAllowedOutputL --"), this);
1.755 +}
1.756 +
1.757 +void CNGAPostProcHwDevice::SetPostProcessTypesL(TUint32 /*aCombination*/)
1.758 +{
1.759 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPostProcessTypesL ++"), this);
1.760 +
1.761 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPostProcessTypesL --"), this);
1.762 +}
1.763 +
1.764 +void CNGAPostProcHwDevice::SetInputCropOptionsL(const TRect& /*aRect*/)
1.765 +{
1.766 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputCropOptionsL ++"), this);
1.767 +
1.768 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputCropOptionsL --"), this);
1.769 +}
1.770 +
1.771 +void CNGAPostProcHwDevice::SetYuvToRgbOptionsL( const TYuvToRgbOptions& /*aOptions*/, const TYuvFormat& /*aYuvFormat*/, TRgbFormat /*aRgbFormat*/)
1.772 +{
1.773 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetYuvToRgbOptionsL ++"), this);
1.774 +
1.775 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetYuvToRgbOptionsL --"), this);
1.776 +}
1.777 +
1.778 +void CNGAPostProcHwDevice::SetYuvToRgbOptionsL(const TYuvToRgbOptions& /*aOptions*/)
1.779 +{
1.780 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetYuvToRgbOptionsL ++"), this);
1.781 +
1.782 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetYuvToRgbOptionsL --"), this);
1.783 +}
1.784 +
1.785 +void CNGAPostProcHwDevice::SetRotateOptionsL(TRotationType )
1.786 +{
1.787 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetRotateOptionsL ++"), this);
1.788 +
1.789 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetRotateOptionsL --"));
1.790 +}
1.791 +
1.792 +void CNGAPostProcHwDevice::SetScaleOptionsL(const TSize& /*aTargetSize*/, TBool /*aAntiAliasFiltering*/)
1.793 +{
1.794 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetScaleOptionsL ++"), this);
1.795 +
1.796 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetScaleOptionsL --"), this);
1.797 +}
1.798 +
1.799 +void CNGAPostProcHwDevice::SetOutputCropOptionsL(const TRect& /*aRect*/)
1.800 +{
1.801 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetOutputCropOptionsL ++"), this);
1.802 +
1.803 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetOutputCropOptionsL --"), this);
1.804 +}
1.805 +
1.806 +void CNGAPostProcHwDevice::SetPostProcSpecificOptionsL(const TDesC8& )
1.807 +{
1.808 + //ignore
1.809 +}
1.810 +
1.811 +void CNGAPostProcHwDevice::CommitL()
1.812 +{
1.813 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CommitL ++"), this);
1.814 +
1.815 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CommitL --"), this);
1.816 +}
1.817 +
1.818 +void CNGAPostProcHwDevice::Revert()
1.819 +{
1.820 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Revert ++"), this);
1.821 +
1.822 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Revert --"), this);
1.823 +}
1.824 +
1.825 +void CNGAPostProcHwDevice::StartDirectScreenAccessL( const TRect& /*aVideoRect*/, CFbsScreenDevice& /*aScreenDevice*/, const TRegion& /*aClipRegion*/)
1.826 +{
1.827 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:StartDSA ++"), this);
1.828 +
1.829 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:StartDSA --"), this);
1.830 +}
1.831 +
1.832 +void CNGAPostProcHwDevice::AbortDirectScreenAccess()
1.833 +{
1.834 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AbortDSA ++"), this);
1.835 +
1.836 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AbortDSA --"), this);
1.837 +}
1.838 +
1.839 +void CNGAPostProcHwDevice::SetScreenClipRegion(const TRegion& /*aRegion*/)
1.840 +{
1.841 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetScreenClipRegion ++"), this);
1.842 +
1.843 +
1.844 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetScreenClipRegion --"), this);
1.845 +}
1.846 +
1.847 +void CNGAPostProcHwDevice::SetPauseOnClipFail(TBool )
1.848 +{
1.849 + //ignore. Post Processor will always behave as aPause==False.
1.850 +}
1.851 +
1.852 +TBool CNGAPostProcHwDevice::IsPlaying()
1.853 +{
1.854 + if( iPPState == EPlaying)
1.855 + {
1.856 + return ETrue;
1.857 + }
1.858 + else
1.859 + {
1.860 + return EFalse;
1.861 + }
1.862 +}
1.863 +
1.864 +void CNGAPostProcHwDevice::Redraw()
1.865 +{
1.866 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw ++"), this);
1.867 + TInt err = KErrNone;
1.868 + if(iRedrawSurfaceInUse && !iRedrawDone)
1.869 + {
1.870 + err = AddHints();
1.871 + if (err != KErrNone)
1.872 + {
1.873 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw -- failed to AddHints %d"),
1.874 + this, err);
1.875 + iProxy->MdvppFatalError(this, err);
1.876 + return;
1.877 + }
1.878 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw registering the temp surface"), this);
1.879 + err = RegisterSurface(iSurfaceId);
1.880 + if (err != KErrNone)
1.881 + {
1.882 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw -- failed to Register Surface %d"),
1.883 + this, err);
1.884 + iSurfaceHandler->DestroySurface(iSurfaceId);
1.885 + iSurfaceId = TSurfaceId::CreateNullId();
1.886 + iProxy->MdvppFatalError(this, err);
1.887 + return;
1.888 + }
1.889 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw registering the temp surface done"), this);
1.890 + iSessionManager->PostPicture(iSurfaceId, 0, 1, EFalse);
1.891 + PublishSurfaceCreated();
1.892 + iRedrawDone = ETrue;
1.893 + }
1.894 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw --"), this);
1.895 +}
1.896 +
1.897 +void CNGAPostProcHwDevice::Start()
1.898 +{
1.899 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Start ++"), this);
1.900 + iPPState = EPlaying;
1.901 + AttemptToPost();
1.902 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Start --"), this);
1.903 +}
1.904 +
1.905 +void CNGAPostProcHwDevice::Stop()
1.906 +{
1.907 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Stop ++"), this);
1.908 + iPPState = EStopped;
1.909 + iPostingTimer->Cancel();
1.910 + ReleaseInputQ();
1.911 +
1.912 + RDebug::Printf("------ Statistics of Post Processor ------");
1.913 + RDebug::Printf(" Pictures Received : %d", iPictureCounters.iTotalPictures);
1.914 + RDebug::Printf(" Pictures Displayed: %d", iPictureCounters.iPicturesDisplayed);
1.915 + RDebug::Printf(" Pictures Skipped : %d", iPictureCounters.iPicturesSkipped);
1.916 + RDebug::Printf("------------------------------------------");
1.917 +
1.918 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Stop --"), this);
1.919 +}
1.920 +
1.921 +void CNGAPostProcHwDevice::Pause()
1.922 +{
1.923 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Pause ++"), this);
1.924 + iPPState = EPaused;
1.925 + iPostingTimer->Cancel();
1.926 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Pause --"), this);
1.927 +}
1.928 +
1.929 +void CNGAPostProcHwDevice::Resume()
1.930 +{
1.931 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Resume ++"), this);
1.932 + iPPState = EPlaying;
1.933 + AttemptToPost();
1.934 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Resume --"), this);
1.935 +}
1.936 +
1.937 +void CNGAPostProcHwDevice::SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition)
1.938 +{
1.939 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPosition ++"), this);
1.940 +
1.941 + if (iPPState == EInitializing)
1.942 + {
1.943 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPosition FAILED: Unexpected state"), this);
1.944 + return;
1.945 + }
1.946 + if (iPPState == EPaused)
1.947 + {
1.948 + iFirstPictureUpdated = EFalse;
1.949 + }
1.950 + iCurrentPlaybackPosition = aPlaybackPosition;
1.951 +
1.952 + ReleaseInputQ();
1.953 +
1.954 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPosition --"), this);
1.955 +}
1.956 +
1.957 +void CNGAPostProcHwDevice::FreezePicture(const TTimeIntervalMicroSeconds& )
1.958 +{
1.959 + //TODO:
1.960 +}
1.961 +
1.962 +void CNGAPostProcHwDevice::ReleaseFreeze(const TTimeIntervalMicroSeconds& )
1.963 +{
1.964 + //TODO:
1.965 +}
1.966 +
1.967 +TTimeIntervalMicroSeconds
1.968 +CNGAPostProcHwDevice::PlaybackPosition()
1.969 +{
1.970 + if (iPPState == EInitializing)
1.971 + {
1.972 + return TTimeIntervalMicroSeconds(0);
1.973 + }
1.974 +
1.975 + return iCurrentPlaybackPosition;
1.976 +}
1.977 +
1.978 +TUint CNGAPostProcHwDevice::PictureBufferBytes()
1.979 +{ //TODO
1.980 + return 0;
1.981 +}
1.982 +
1.983 +void CNGAPostProcHwDevice::GetPictureCounters( CMMFDevVideoPlay::TPictureCounters& aCounters)
1.984 +{
1.985 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetPictureCounters ++"), this);
1.986 +
1.987 + if (iPPState == EInitializing)
1.988 + return;
1.989 + aCounters = iPictureCounters;
1.990 +
1.991 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetPictureCounters --"), this);
1.992 +}
1.993 +
1.994 +void CNGAPostProcHwDevice::SetComplexityLevel(TUint )
1.995 +{
1.996 + //not required
1.997 +}
1.998 +
1.999 +TUint CNGAPostProcHwDevice::NumComplexityLevels()
1.1000 +{
1.1001 + //not required
1.1002 + return 1;
1.1003 +}
1.1004 +
1.1005 +void CNGAPostProcHwDevice::GetComplexityLevelInfo(TUint , CMMFDevVideoPlay::TComplexityLevelInfo& )
1.1006 +{
1.1007 + //not required
1.1008 +}
1.1009 +
1.1010 +void CNGAPostProcHwDevice::ReturnPicture(TVideoPicture* )
1.1011 +{
1.1012 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReturnPicture +-"), this);
1.1013 + //not required for direct rendering
1.1014 +}
1.1015 +
1.1016 +TBool CNGAPostProcHwDevice::GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& /*aFormat*/)
1.1017 +{
1.1018 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL %d %d ++"), this, iVBMEnabled, iProcessQ.Count());
1.1019 + TVideoPicture* pic = NULL;
1.1020 + TInt err = KErrNone;
1.1021 + TBool frameAvailable =EFalse;
1.1022 + tWndParam inputCropWindow;
1.1023 + tWndParam outputCropWindow;
1.1024 + tBaseVideoFrame inputFrame;
1.1025 + inputFrame.lum = NULL;
1.1026 +
1.1027 + if(aPictureData.iDataFormat == ERgbFbsBitmap)
1.1028 + {
1.1029 + if(iProcessQ.Count())
1.1030 + {
1.1031 + pic = iProcessQ[0]; //frame already submitted for display
1.1032 + }
1.1033 + else if(iInputQ.Count())
1.1034 + {
1.1035 + pic = iInputQ[0]; //frame yet to be displayed
1.1036 + }
1.1037 + if(pic)
1.1038 + {
1.1039 + if (iVBMEnabled)
1.1040 + {
1.1041 + inputFrame.lum = (TUint8*)pic->iData.iRawData->Ptr();
1.1042 + }
1.1043 + else
1.1044 + {
1.1045 + if (iInputDecoderDevice)
1.1046 + {
1.1047 + MMmfVideoFetchFrame* VFHandler = NULL;
1.1048 + VFHandler = (MMmfVideoFetchFrame*)iInputDecoderDevice->CustomInterface(KUidMMFVideoFetchFrame);
1.1049 + if (VFHandler)
1.1050 + {
1.1051 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL() fetch frame"), this);
1.1052 + inputFrame.lum = (TUint8*)VFHandler->MmvffGetFrame(GetID(pic));
1.1053 + }
1.1054 + else
1.1055 + {
1.1056 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL() decoder yet to implement MMmfVideoFetchFrame CI"), this);
1.1057 + }
1.1058 + }
1.1059 + }
1.1060 + }
1.1061 + if(inputFrame.lum)
1.1062 + {
1.1063 + inputFrame.cb = inputFrame.lum + iPicSize.iWidth * iPicSize.iHeight;
1.1064 +
1.1065 + if( ((iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma1) ||
1.1066 + (iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma2) ||
1.1067 + (iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma3) ))
1.1068 + {
1.1069 + inputFrame.cr = inputFrame.lum + (iPicSize.iWidth * iPicSize.iHeight*5)/4;
1.1070 + }
1.1071 + else
1.1072 + {
1.1073 + inputFrame.cr = inputFrame.lum + (iPicSize.iWidth * iPicSize.iHeight*3)/2;
1.1074 + }
1.1075 +
1.1076 + inputFrame.width = (unsigned short)iPicSize.iWidth;
1.1077 + inputFrame.height = (unsigned short)iPicSize.iHeight;
1.1078 +
1.1079 + outputCropWindow.wndHeight = iPicSize.iHeight;
1.1080 + outputCropWindow.wndWidth = iPicSize.iWidth;
1.1081 + outputCropWindow.xOffset = 0;
1.1082 + outputCropWindow.yOffset = 0;
1.1083 +
1.1084 + inputCropWindow.wndHeight = iPicSize.iHeight;
1.1085 + inputCropWindow.wndWidth = iPicSize.iWidth;
1.1086 + inputCropWindow.xOffset = 0;
1.1087 + inputCropWindow.yOffset = 0;
1.1088 +
1.1089 + RFbsSession fbs;
1.1090 + fbs.Connect();
1.1091 + CFbsBitmap* iOutBitmap = aPictureData.iRgbBitmap;
1.1092 + TInt status = iOutBitmap->Resize(iPicSize);
1.1093 + if (status == KErrNone)
1.1094 + {
1.1095 + // Lock the heap to prevent the FBS server from invalidating the address
1.1096 + iOutBitmap->LockHeap();
1.1097 + TUint8* dataAddress = (TUint8*)iOutBitmap->DataAddress();
1.1098 + err = ColorConvert(&inputFrame, dataAddress, &inputCropWindow, &outputCropWindow);
1.1099 + iOutBitmap->UnlockHeap();
1.1100 + frameAvailable = ETrue;
1.1101 + }
1.1102 + fbs.Disconnect();
1.1103 + }
1.1104 + }
1.1105 + else
1.1106 + {
1.1107 + err = KErrNotSupported;
1.1108 + }
1.1109 + if(err != KErrNone)
1.1110 + {
1.1111 + User::Leave(err);
1.1112 + }
1.1113 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL --"), this);
1.1114 + return(frameAvailable);
1.1115 +}
1.1116 +
1.1117 +void CNGAPostProcHwDevice::InputEnd()
1.1118 +{
1.1119 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:InputEnd ++"), this);
1.1120 +
1.1121 + if (iPPState!=EPlaying && iPPState!=EPaused)
1.1122 + {
1.1123 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:InputEnd FAILED: Unexpected state"), this);
1.1124 + return;
1.1125 + }
1.1126 + iIsInputEnded = ETrue;
1.1127 +
1.1128 + if( (iProcessQ.Count() == 1) && (iInputQ.Count() == 0))
1.1129 + {
1.1130 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:InputEnd() Stream end"), this);
1.1131 + iProxy->MdvppStreamEnd();
1.1132 + }
1.1133 +
1.1134 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:InputEnd --"), this);
1.1135 +}
1.1136 +
1.1137 +TAny* CNGAPostProcHwDevice::CustomInterface(TUid aInterface)
1.1138 +{
1.1139 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CustomInterface UID = %d ++"), this, aInterface.iUid);
1.1140 +
1.1141 + if (aInterface == KUidMmfVideoBufferManagement)
1.1142 + {
1.1143 + return (MMmfVideoBufferManagement *)this;
1.1144 + }
1.1145 + if (aInterface == KUidMMFVideoSurfaceSupport)
1.1146 + {
1.1147 + return (MMMFVideoSurfaceSupport *)this;
1.1148 + }
1.1149 + if (aInterface == KUidMMFVideoSurfaceHandleControl)
1.1150 + {
1.1151 + return (MMmfVideoSurfaceHandleControl *)this;
1.1152 + }
1.1153 + if (aInterface == KUidMmfVideoPlayRateControl)
1.1154 + {
1.1155 + return (MMmfVideoPlayRateControl *)this;
1.1156 + }
1.1157 + if (aInterface == KMmfVideoAdvancedSecureOutputUid)
1.1158 + {
1.1159 + return (MMmfAdvancedVideoSecureOutput *)this;
1.1160 + }
1.1161 + if (aInterface == KUidMmfVideoResourceManagement)
1.1162 + {
1.1163 + return (MMmfVideoResourceObserver *)this;
1.1164 + }
1.1165 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CustomInterface --"), this);
1.1166 + return NULL;
1.1167 +}
1.1168 +
1.1169 +void CNGAPostProcHwDevice::BufferAvailable(TInt aBufId, TInt aStatus)
1.1170 +{
1.1171 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CNGAPostProcHwDevice::BufferAvailable aStatus = %d aBufId = %d++"), this, aStatus, aBufId);
1.1172 + TVideoPicture* pic = NULL;
1.1173 + if((aStatus != KErrNone) && (aStatus != KErrOverflow) && (aStatus != KErrNotVisible))
1.1174 + {
1.1175 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:BufferAvailable FAILED: aStatus = %d"), this, aStatus);
1.1176 + iProxy->MdvppFatalError(this, aStatus);
1.1177 + }
1.1178 +
1.1179 + if(aStatus == KErrOverflow)
1.1180 + {
1.1181 + iOverflowPictureCounter++;
1.1182 + PicturesSkipped();
1.1183 + }
1.1184 +
1.1185 + if (iVBMEnabled)
1.1186 + {
1.1187 + for(TInt i=0; i < iProcessQ.Count(); i++)
1.1188 + {
1.1189 + if(iVBMBufferReferenceQ[aBufId] == iProcessQ[i])
1.1190 + {
1.1191 + pic = iProcessQ[i];
1.1192 + iProcessQ.Remove(i);
1.1193 + ReturnPicToDecoder(pic);
1.1194 + if (iIsColorConversionNeeded)
1.1195 + {
1.1196 + AddPictureToColorConversionQ(pic);
1.1197 + }
1.1198 + else
1.1199 + {
1.1200 + AddPictureToVBMQ(pic);
1.1201 + }
1.1202 + break;
1.1203 + }
1.1204 + }
1.1205 + }
1.1206 + else if (iUsingExternalSurface)
1.1207 + {
1.1208 + for(TInt i=0; i < iProcessQ.Count(); i++)
1.1209 + {
1.1210 + if (aBufId == GetExternalBufferID(iProcessQ[i]))
1.1211 + {
1.1212 + pic = iProcessQ[i];
1.1213 + iProcessQ.Remove(i);
1.1214 + ReturnPicToDecoder(pic);
1.1215 + break;
1.1216 + }
1.1217 + }
1.1218 + }
1.1219 +
1.1220 + if(aStatus == KErrNone)
1.1221 + {
1.1222 + if (!iKeyFrameMode && iPlayRate>KDefPlayRate)
1.1223 + {
1.1224 + if (iSkippedFramesCountingBuffer[iCurrentPosInFramesCountingBuffer]==1)
1.1225 + {
1.1226 + iSkippedFramesCountingBuffer[iCurrentPosInFramesCountingBuffer] = 0;
1.1227 + iSkippedFramesInLast64Frames--;
1.1228 + }
1.1229 + iCurrentPosInFramesCountingBuffer = ++iCurrentPosInFramesCountingBuffer%64;
1.1230 + }
1.1231 + iPictureCounters.iPicturesDisplayed++;
1.1232 + if (iStepFrameCount != 0)
1.1233 + {
1.1234 + iStepFrameCount > 0 ? iStepFrameCount-- : iStepFrameCount++;
1.1235 + if (iStepFrameCount==0 && iFPObserver)
1.1236 + {
1.1237 + iFPObserver->MmvproStepFrameComplete(pic->iTimestamp);
1.1238 + }
1.1239 + }
1.1240 + }
1.1241 +
1.1242 + if(iPPState == EPlaying)
1.1243 + {
1.1244 + AttemptToPost();
1.1245 + }
1.1246 +
1.1247 + if( iIsInputEnded && (iProcessQ.Count() == 1) && (iInputQ.Count() == 0))
1.1248 + {
1.1249 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:BufferAvailable() Stream end"), this);
1.1250 + iProxy->MdvppStreamEnd();
1.1251 + }
1.1252 +
1.1253 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CNGAPostProcHwDevice::BufferAvailable --"), this);
1.1254 +}
1.1255 +
1.1256 +//=== MMmfVideoBufferManagement ===
1.1257 +void CNGAPostProcHwDevice::MmvbmSetObserver(MMmfVideoBufferManagementObserver* aObserver)
1.1258 +{
1.1259 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetObserver() ++"), this);
1.1260 +
1.1261 + if (iPPState != EInitializing)
1.1262 + {
1.1263 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetObserver FAILED: Unexpected state"), this);
1.1264 + iProxy->MdvppFatalError(this, KErrNotReady);
1.1265 + }
1.1266 +
1.1267 + iVBMObserver = aObserver;
1.1268 +
1.1269 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetObserver() --"), this);
1.1270 +}
1.1271 +
1.1272 +
1.1273 +void CNGAPostProcHwDevice::MmvbmEnable(TBool aEnable)
1.1274 +{
1.1275 + if (iPPState != EInitializing)
1.1276 + {
1.1277 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmEnable FAILED: Unexpected state"), this);
1.1278 + iProxy->MdvppFatalError(this, KErrNotReady);
1.1279 + }
1.1280 +
1.1281 + iVBMEnabled = aEnable;
1.1282 +}
1.1283 +
1.1284 +void CNGAPostProcHwDevice::MmvbmSetBufferOptionsL(const TBufferOptions& aOptions)
1.1285 +{
1.1286 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetBufferOptionsL ++"), this);
1.1287 +
1.1288 + if (iPPState != EInitializing)
1.1289 + {
1.1290 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetBufferOptionsL FAILED: Unexpected state"), this);
1.1291 + User::Leave(KErrNotReady);
1.1292 + }
1.1293 +
1.1294 + if (aOptions.iNumInputBuffers > KMaxVBMBuffers
1.1295 + || aOptions.iNumInputBuffers <= 1) //at least two buffers
1.1296 + {
1.1297 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetBufferOptionsL FAILED: Input buffer count limit"), this);
1.1298 + User::Leave(KErrNotSupported);
1.1299 + }
1.1300 +
1.1301 + if (aOptions.iNumInputBuffers == 0
1.1302 + || aOptions.iBufferSize.iWidth <= KMinVBMInputWidth
1.1303 + || aOptions.iBufferSize.iHeight <= KMinVBMInputHeight
1.1304 + || aOptions.iBufferSize.iWidth > KMaxVBMInputWidth
1.1305 + || aOptions.iBufferSize.iHeight > KMaxVBMInputHeight)
1.1306 + {
1.1307 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetBufferOptionsL FAILED: Unexpected buffer size"), this);
1.1308 + User::Leave(KErrArgument);
1.1309 + }
1.1310 +
1.1311 + iVBMBufferOptions.iNumInputBuffers = aOptions.iNumInputBuffers;
1.1312 + iVBMBufferOptions.iBufferSize = aOptions.iBufferSize;
1.1313 +
1.1314 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetBufferOptionsL --"), this);
1.1315 +}
1.1316 +
1.1317 +void CNGAPostProcHwDevice::MmvbmGetBufferOptions(TBufferOptions& aOptions)
1.1318 +{
1.1319 + if (iPPState == EInitializing)
1.1320 + {
1.1321 + aOptions = iVBMBufferOptions;
1.1322 + }
1.1323 + else
1.1324 + {
1.1325 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferOptions FAILED: Unexpected state"), this);
1.1326 + iProxy->MdvppFatalError(this, KErrNotReady);
1.1327 + }
1.1328 +}
1.1329 +
1.1330 +TVideoPicture* CNGAPostProcHwDevice::MmvbmGetBufferL(const TSize& aSize)
1.1331 + {
1.1332 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() ++"), this);
1.1333 +
1.1334 + TInt err = KErrNone;
1.1335 + TVideoPicture* lPic = NULL;
1.1336 +
1.1337 + if (iPPState == EInitializing)
1.1338 + {
1.1339 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() FAILED: Unexpected state"), this);
1.1340 + User::Leave(KErrNotReady);
1.1341 + }
1.1342 +
1.1343 + if (aSize.iWidth < KMinVBMInputWidth
1.1344 + || aSize.iHeight < KMinVBMInputHeight
1.1345 + || aSize.iWidth > iVBMBufferOptions.iBufferSize.iWidth
1.1346 + || aSize.iHeight > iVBMBufferOptions.iBufferSize.iHeight)
1.1347 + {
1.1348 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() FAILED: Unexpected buffer size w=%d h=%d "), this,aSize.iWidth,aSize.iHeight );
1.1349 + User::Leave(KErrNotSupported);
1.1350 + }
1.1351 +
1.1352 + if(iVBMBufferReferenceQ.Count() == 0)
1.1353 + {
1.1354 + iPicSize = aSize;
1.1355 + err = SetupSurface(aSize);
1.1356 + if(err)
1.1357 + {
1.1358 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() Surface Setup Failed %d"), this, err);
1.1359 + User::Leave(err);
1.1360 + }
1.1361 + }
1.1362 +
1.1363 + if(!iVBMBufferQ.Count())
1.1364 + {
1.1365 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() WARNING: Queue buffer count zero"), this);
1.1366 + return NULL;
1.1367 + }
1.1368 +
1.1369 + lPic = iVBMBufferQ[0];
1.1370 + iVBMBufferQ.Remove(0);
1.1371 +
1.1372 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() -- %d"), this, lPic);
1.1373 + return lPic;
1.1374 +}
1.1375 +
1.1376 +void CNGAPostProcHwDevice::MmvbmReleaseBuffer(TVideoPicture* aBuffer)
1.1377 +{
1.1378 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmReleaseBuffer() ++"), this);
1.1379 +
1.1380 + if(!aBuffer)
1.1381 + {
1.1382 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmReleaseBuffer() FAILED: Invalid buffer ptr"), this);
1.1383 + iProxy->MdvppFatalError(this, KErrArgument);
1.1384 + }
1.1385 +
1.1386 + TInt err = iVBMBufferQ.Append(aBuffer);
1.1387 + if (err)
1.1388 + {
1.1389 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmReleaseBuffer() FAILED: Failed to append"), this);
1.1390 + iProxy->MdvppFatalError(this, err);
1.1391 + }
1.1392 +
1.1393 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmReleaseBuffer() --"), this);
1.1394 +}
1.1395 +
1.1396 +//=== MMMFVideoSurfaceSupport ===
1.1397 +
1.1398 +void CNGAPostProcHwDevice::MmvssUseSurfaces()
1.1399 +{
1.1400 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssUseSurfaces() ++"), this);
1.1401 + // do nothing
1.1402 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssUseSurfaces() --"), this);
1.1403 +}
1.1404 +
1.1405 +void CNGAPostProcHwDevice::MmvssSetObserver(MMMFVideoSurfaceObserver& aObserver)
1.1406 +{
1.1407 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSetObserver() ++"), this);
1.1408 + iVideoSurfaceObserver = &aObserver;
1.1409 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSetObserver() --"), this);
1.1410 +}
1.1411 +
1.1412 +void CNGAPostProcHwDevice::MmvssGetSurfaceParametersL(TSurfaceId& aSurfaceId,
1.1413 + TRect& aCropRect, TVideoAspectRatio& aPixelAspectRatio)
1.1414 +{
1.1415 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() ++"), this);
1.1416 +
1.1417 + iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo);
1.1418 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() \
1.1419 + surfaceWidth = %d surfaceHeight = %d SurfaceId = 0x%x --"),
1.1420 + this, iInfo().iSize.iWidth, iInfo().iSize.iHeight, iSurfaceId);
1.1421 + aSurfaceId = iSurfaceId;
1.1422 + aCropRect = TRect(0, 0, iInfo().iSize.iWidth, iInfo().iSize.iHeight);
1.1423 + if((iPicSize.iWidth > 0) && (iPicSize.iHeight > 0))
1.1424 + {
1.1425 + aCropRect.Intersection( iPicSize);
1.1426 + }
1.1427 + aPixelAspectRatio = TVideoAspectRatio(iAspectRatioNum,iAspectRatioDenom);
1.1428 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() \
1.1429 + cropRectWidth = %d cropRectHeight = %d"), this, aCropRect.Width(), aCropRect.Height());
1.1430 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() \
1.1431 + PAR Num = %d PAR Denom = %d"), this, aPixelAspectRatio.iNumerator, aPixelAspectRatio.iDenominator);
1.1432 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() --"), this);
1.1433 +}
1.1434 +
1.1435 +void CNGAPostProcHwDevice::MmvssSurfaceRemovedL(const TSurfaceId& aSurfaceId)
1.1436 +{
1.1437 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL()++"), this);
1.1438 + if(!aSurfaceId.IsNull())
1.1439 + {
1.1440 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL(): UnregisterSurface ID = 0x%x"), this, aSurfaceId );
1.1441 + TInt numScreens = iWsSession.NumberOfScreens();
1.1442 + for(TInt i=0;i < numScreens;i++)
1.1443 + {
1.1444 + iWsSession.UnregisterSurface(i, aSurfaceId);
1.1445 + }
1.1446 + iWsSession.Flush();
1.1447 + iSurfaceHandler->DestroySurface(aSurfaceId);
1.1448 + if(iSurfaceId == aSurfaceId)
1.1449 + {
1.1450 + iSurfaceCreatedEventPublished = EFalse;
1.1451 + iSurfaceId = TSurfaceId::CreateNullId();
1.1452 + iChunk.Close();
1.1453 + }
1.1454 + }
1.1455 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL() --"), this);
1.1456 +}
1.1457 +
1.1458 +// === MMmfVideoPropertiesObserver ===
1.1459 +
1.1460 +void CNGAPostProcHwDevice::MmvpoUpdateVideoProperties(const TYuvFormat& aYuvFormat, const TSize& aPictureSize)
1.1461 +{
1.1462 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties ++"), this);
1.1463 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties PAR \
1.1464 + iAspectRatioNum = %d, iAspectRatioDenom = %d"), this,
1.1465 + aYuvFormat.iAspectRatioNum,aYuvFormat.iAspectRatioDenom);
1.1466 + iPicSize = aPictureSize;
1.1467 + iAspectRatioNum = aYuvFormat.iAspectRatioNum;
1.1468 + iAspectRatioDenom = aYuvFormat.iAspectRatioDenom;
1.1469 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties Picture Size \
1.1470 + iWidth = %d, iHeight = %d, iSurfaceCreatedEventPublished = %d"),
1.1471 + this, iPicSize.iWidth,iPicSize.iHeight, iSurfaceCreatedEventPublished?1:0);
1.1472 +
1.1473 + if(iVPObserver)
1.1474 + {
1.1475 + iVPObserver->MmvpoUpdateVideoProperties(aYuvFormat, aPictureSize);
1.1476 + }
1.1477 + if(iVideoSurfaceObserver && iSurfaceCreatedEventPublished)
1.1478 + {
1.1479 + iVideoSurfaceObserver->MmvsoSurfaceParametersChanged();
1.1480 + }
1.1481 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties --"), this);
1.1482 +}
1.1483 +
1.1484 +// === MMmfVideoResourceObserver ===
1.1485 +
1.1486 +void CNGAPostProcHwDevice::MmvroResourcesLost(TUid )
1.1487 +{
1.1488 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost ++"), this);
1.1489 + if(!iResourceLost)
1.1490 + {
1.1491 + iResourceLost = ETrue;
1.1492 + iRedrawDone = EFalse;
1.1493 + Pause();
1.1494 + ReleaseInputQ();
1.1495 + iSessionManager->CancelUpdate();
1.1496 + ReleaseProcessQ();
1.1497 + if(iVideoSurfaceObserver && iSurfaceCreatedEventPublished)
1.1498 + {
1.1499 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost - Telling client to remove surface"), this);
1.1500 + iVideoSurfaceObserver->MmvsoRemoveSurface();
1.1501 + iSurfaceCreatedEventPublished = EFalse;
1.1502 + }
1.1503 + }
1.1504 + else if(iResourceLost && iRedrawDone)
1.1505 + {
1.1506 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost ResourceLost happening \
1.1507 + while Postprocessor is already in ResourceLoss state"),
1.1508 + this);
1.1509 + iProxy->MdvppFatalError(this, KErrHardwareNotAvailable);
1.1510 + return;
1.1511 + }
1.1512 + else
1.1513 + {
1.1514 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost Ignoring the \
1.1515 + duplicate ResourceLoss call"),
1.1516 + this);
1.1517 + }
1.1518 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost --"), this);
1.1519 +}
1.1520 +
1.1521 +// === MMmfVideoPropertiesNotifier ===
1.1522 +
1.1523 +void CNGAPostProcHwDevice::MmvpnSetObserver(MMmfVideoPropertiesObserver* aObserver)
1.1524 +{
1.1525 + PP_DEBUG(_L("ppHwDev[%x]::MmvpnSetObserver ++"), this);
1.1526 + iVPObserver = aObserver;
1.1527 + PP_DEBUG(_L("ppHwDev[%x]::MmvpnSetObserver --"), this);
1.1528 +}
1.1529 +
1.1530 +void CNGAPostProcHwDevice::MmvroResourcesRestored(TUid )
1.1531 +{
1.1532 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvroResourcesRestored ++"), this);
1.1533 + iFirstPictureUpdated = EFalse;
1.1534 + iResourceLost = EFalse;
1.1535 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvroResourcesRestored state=%d --"),
1.1536 + this, iPPState);
1.1537 +}
1.1538 +
1.1539 +void CNGAPostProcHwDevice::MmvshcSetSurfaceHandle(const TSurfaceId &aSurfaceID)
1.1540 +{
1.1541 +
1.1542 + SetupExternalSurface(aSurfaceID);
1.1543 +
1.1544 +}
1.1545 +
1.1546 +void CNGAPostProcHwDevice::MmvshcRedrawBufferToSurface(TPtrC8& aRedrawBuffer)
1.1547 +{
1.1548 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface ++"), this);
1.1549 +
1.1550 + TUint8* lPtr;
1.1551 + TInt offset;
1.1552 +
1.1553 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface -- Creating %d x %d surface"), this, iPicSize.iWidth, iPicSize.iHeight);
1.1554 +
1.1555 + TInt err = KErrNone;
1.1556 + SetSurfaceAttributes(iPicSize, 1);
1.1557 +
1.1558 + err = iSurfaceHandler->CreateSurface(iAttributes, iSurfaceId);
1.1559 + if (err != KErrNone)
1.1560 + {
1.1561 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to create Surface %d"),
1.1562 + this, err);
1.1563 + iProxy->MdvppFatalError(this, err);
1.1564 + return;
1.1565 + }
1.1566 +
1.1567 + err = iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo);
1.1568 + if (err != KErrNone)
1.1569 + {
1.1570 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to get Surface info %d"),
1.1571 + this, err);
1.1572 + iSurfaceHandler->DestroySurface(iSurfaceId);
1.1573 + iSurfaceId = TSurfaceId::CreateNullId();
1.1574 + iProxy->MdvppFatalError(this, err);
1.1575 + return;
1.1576 + }
1.1577 +
1.1578 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface() \
1.1579 + surfaceWidth = %d surfaceHeight = %d surfaceStride = %d"), this, iInfo().iSize.iWidth, iInfo().iSize.iHeight, iInfo().iStride);
1.1580 +
1.1581 + TInt redrawBufferSize = aRedrawBuffer.Size();
1.1582 + TInt surfaceSize = iInfo().iStride * iInfo().iSize.iHeight;
1.1583 +
1.1584 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface RedrawBuffer size= %d Surface size = %d"), this, redrawBufferSize, surfaceSize);
1.1585 +
1.1586 + // Check whether redraw buffer will fit onto the surface.
1.1587 + // If this check fails then we won't raise a fatal error - We just won't create the redraw surface
1.1588 + if (redrawBufferSize > surfaceSize)
1.1589 + {
1.1590 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface Redraw buffer size larger than surface size"), this);
1.1591 + iSurfaceHandler->DestroySurface(iSurfaceId);
1.1592 + iSurfaceId = TSurfaceId::CreateNullId();
1.1593 + return;
1.1594 + }
1.1595 +
1.1596 + err = iSurfaceHandler->MapSurface(iSurfaceId, iChunk);
1.1597 + if (err != KErrNone)
1.1598 + {
1.1599 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to map Surface %d"),
1.1600 + this, err);
1.1601 + iSurfaceHandler->DestroySurface(iSurfaceId);
1.1602 + iSurfaceId = TSurfaceId::CreateNullId();
1.1603 + iProxy->MdvppFatalError(this, err);
1.1604 + return;
1.1605 + }
1.1606 +
1.1607 + if((err = iSurfaceHandler->GetBufferOffset(iSurfaceId, 0, offset)) != KErrNone)
1.1608 + {
1.1609 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface offset query failed %d"), this, err);
1.1610 + iSurfaceHandler->DestroySurface(iSurfaceId);
1.1611 + iSurfaceId = TSurfaceId::CreateNullId();
1.1612 + iChunk.Close();
1.1613 + iProxy->MdvppFatalError(this, err);
1.1614 + return;
1.1615 + }
1.1616 +
1.1617 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface offset = %d"), this, offset);
1.1618 +
1.1619 + lPtr = reinterpret_cast<TUint8*>(iChunk.Base() + offset);
1.1620 + memcpy((TAny *)lPtr, (TAny *)aRedrawBuffer.Ptr(), redrawBufferSize);
1.1621 +
1.1622 + iRedrawSurfaceInUse = ETrue;
1.1623 +
1.1624 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface(): New surface = 0x%x"), this, iSurfaceId);
1.1625 +
1.1626 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface error = %d --"), this, err);
1.1627 +}
1.1628 +
1.1629 +TInt CNGAPostProcHwDevice::SetupExternalSurface(const TSurfaceId &aSurfaceID)
1.1630 +{
1.1631 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface(): aSurfaceID = 0x%x"), this, aSurfaceID );
1.1632 +
1.1633 + TInt err = KErrNone;
1.1634 +
1.1635 + if(!iSurfaceId.IsNull())
1.1636 + {
1.1637 + if (iVideoSurfaceObserver && iSurfaceCreatedEventPublished)
1.1638 + {
1.1639 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface - Telling client to remove old surface"), this);
1.1640 + iVideoSurfaceObserver->MmvsoRemoveSurface();
1.1641 + iSurfaceCreatedEventPublished = EFalse;
1.1642 + }
1.1643 + else
1.1644 + {
1.1645 + // We never told the client about the surface, so we must destroy it ourselves
1.1646 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface - Destroying old surface"), this);
1.1647 + TInt numScreens = iWsSession.NumberOfScreens();
1.1648 + for(TInt i=0;i < numScreens;i++)
1.1649 + {
1.1650 + iWsSession.UnregisterSurface(i, iSurfaceId);
1.1651 + }
1.1652 + iWsSession.Flush();
1.1653 + iSurfaceHandler->DestroySurface(iSurfaceId);
1.1654 + }
1.1655 +
1.1656 + iChunk.Close();
1.1657 + }
1.1658 +
1.1659 + iSurfaceId = aSurfaceID;
1.1660 + iUsingExternalSurface = ETrue;
1.1661 + iRedrawSurfaceInUse = EFalse;
1.1662 +
1.1663 + // Create the surface handler if it doesn't exist.
1.1664 + if (!iSurfaceHandler)
1.1665 + {
1.1666 + TRAP(err, iSurfaceHandler = CNGAPostProcSurfaceHandler::NewL());
1.1667 + if (err != KErrNone)
1.1668 + {
1.1669 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface -- failed to create SurfaceHandler."), this);
1.1670 + return err;
1.1671 + }
1.1672 + }
1.1673 +
1.1674 + err = iSurfaceHandler->OpenSurface(iSurfaceId);
1.1675 + if (err != KErrNone)
1.1676 + {
1.1677 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface -- failed OpenSurface %d"),
1.1678 + this, err);
1.1679 + return err;
1.1680 + }
1.1681 + err = AddHints();
1.1682 + if (err != KErrNone)
1.1683 + {
1.1684 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface -- failed to AddHints %d"),
1.1685 + this, err);
1.1686 + return err;
1.1687 + }
1.1688 + err = RegisterSurface(iSurfaceId);
1.1689 + if (err != KErrNone)
1.1690 + {
1.1691 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface -- failed RegisterSurface %d"),
1.1692 + this, err);
1.1693 + iSurfaceHandler->DestroySurface(iSurfaceId);
1.1694 + iSurfaceId = TSurfaceId::CreateNullId();
1.1695 + return err;
1.1696 + }
1.1697 +
1.1698 + err = iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo);
1.1699 + if (err != KErrNone)
1.1700 + {
1.1701 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface -- failed to get Surface info %d"),
1.1702 + this, err);
1.1703 + return err;
1.1704 + }
1.1705 +
1.1706 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface err=%d"), this, err);
1.1707 + return err;
1.1708 +}
1.1709 +
1.1710 +//=== Internal ===
1.1711 +TVideoPicture* CNGAPostProcHwDevice::CreateBuffersL(TInt aBufId)
1.1712 +{
1.1713 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateBuffersL ++"), this);
1.1714 +
1.1715 + TVideoPicture* lVideoPicture = NULL;
1.1716 + TUint8* lPtr;
1.1717 + TPtr8* lTemp;
1.1718 + TInt offset;
1.1719 +
1.1720 + lVideoPicture = new (ELeave) TVideoPicture;
1.1721 + CleanupStack::PushL(lVideoPicture);
1.1722 + if(TInt err = iSurfaceHandler->GetBufferOffset(iSurfaceId, aBufId, offset) != KErrNone)
1.1723 + {
1.1724 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateBuffersL offset query failed %d"), this, err);
1.1725 + }
1.1726 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateBuffersL offset = %d id =%d --"), this, offset, aBufId);
1.1727 +
1.1728 + lPtr = reinterpret_cast<TUint8*>(iChunk.Base() + offset);
1.1729 +
1.1730 + lTemp = new (ELeave) TPtr8(lPtr, 0, (iVideoFrameBufSize ));
1.1731 + CleanupStack::PushL(lTemp);
1.1732 +
1.1733 + lVideoPicture->iData.iRawData = lTemp;
1.1734 + lVideoPicture->iHeader = NULL ;
1.1735 + lVideoPicture->iLayerBitRates = NULL ;
1.1736 +
1.1737 + CleanupStack::Pop(2);
1.1738 +
1.1739 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateVBMBuffersL --"), this);
1.1740 + return lVideoPicture;
1.1741 +}
1.1742 +
1.1743 +void CNGAPostProcHwDevice::CreateVBMBuffersL()
1.1744 +{
1.1745 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateVBMBuffersL ++"), this);
1.1746 +
1.1747 + TInt err = KErrNone;
1.1748 + TVideoPicture* pic = NULL;
1.1749 + iVBMBufferReferenceQ.Reset();
1.1750 + iVBMBufferQ.Reset();
1.1751 + iColorConversionQ.Reset();
1.1752 +
1.1753 + for(TInt i = 0; i < iVBMBufferOptions.iNumInputBuffers; i++)
1.1754 + {
1.1755 + TRAP(err, pic = CreateBuffersL(i));
1.1756 + if (err != KErrNone)
1.1757 + {
1.1758 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create VBM buffer %d"), this, err);
1.1759 + User::Leave(err);
1.1760 + }
1.1761 +
1.1762 + // This will hold the references which will be used in destructor
1.1763 + User::LeaveIfError(iVBMBufferReferenceQ.Append(pic));
1.1764 + User::LeaveIfError(iVBMBufferQ.Append(pic));
1.1765 + }
1.1766 + if(iIsColorConversionNeeded)
1.1767 + {
1.1768 + for(TInt i = iVBMBufferOptions.iNumInputBuffers ;
1.1769 + i < (iVBMBufferOptions.iNumInputBuffers + KColorConversionBuffers ); i++)
1.1770 + {
1.1771 + TRAP(err, pic = CreateBuffersL(i));
1.1772 + if (err != KErrNone)
1.1773 + {
1.1774 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create VBM buffer %d"), this, err);
1.1775 + User::Leave(err);
1.1776 + }
1.1777 +
1.1778 + // This will hold the references which will be used in destructor
1.1779 + User::LeaveIfError(iVBMBufferReferenceQ.Append(pic));
1.1780 + User::LeaveIfError(iColorConversionQ.Append(pic));
1.1781 + }
1.1782 + }
1.1783 +
1.1784 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateVBMBuffersL --"), this);
1.1785 +}
1.1786 +
1.1787 +void CNGAPostProcHwDevice::ReturnPicToDecoder(TVideoPicture* aPic)
1.1788 +{
1.1789 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReturnPicToDecoder ++"), this);
1.1790 + if (aPic == NULL)
1.1791 + {
1.1792 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputPicture FAILED: Invalid pic ptr."), this);
1.1793 + return;
1.1794 + }
1.1795 +
1.1796 + if (iInputDecoderDevice)
1.1797 + {
1.1798 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputPicture .. before return picture. 2"), this);
1.1799 + iInputDecoderDevice->ReturnPicture(aPic);
1.1800 + }
1.1801 +
1.1802 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReturnPicToDecoder --"), this);
1.1803 +}
1.1804 +
1.1805 +TInt CNGAPostProcHwDevice::AttemptToPost()
1.1806 +{
1.1807 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AttemptToPost ++ Q:%d"), this, iInputQ.Count());
1.1808 + if (iPPState == EPaused)
1.1809 + {
1.1810 + return KErrNone;
1.1811 + }
1.1812 +
1.1813 + TInt err = KErrNotReady;
1.1814 + TInt count = iInputQ.Count();
1.1815 + TBool bDone = EFalse;
1.1816 + TVideoPicture* pic = PeekQ();
1.1817 + while(pic && !bDone)
1.1818 + {
1.1819 + if(!IsGceReady())
1.1820 + {
1.1821 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AttemptToPost GCE not ready"), this );
1.1822 + return err; //no need to catch this error
1.1823 + }
1.1824 + TInt64 delta = 0;
1.1825 + TTimeToPost iTimeToPost = (TTimeToPost)IsTimeToPost(pic, delta);
1.1826 + switch(iTimeToPost)
1.1827 + {
1.1828 + case EDelayIt:
1.1829 + {
1.1830 + iPostingTimer->Cancel();
1.1831 + SetTimer(delta);
1.1832 + bDone = ETrue;
1.1833 + }
1.1834 + break;
1.1835 + case EPostIt:
1.1836 + {
1.1837 + RemoveFromQ(); // remove the pic that was returned by PeekQ
1.1838 + if(iIsColorConversionNeeded)
1.1839 + {
1.1840 + TVideoPicture* ccPic;
1.1841 + ccPic = DoColorConvert(pic); // output will be in ccPic
1.1842 + pic = ccPic;
1.1843 + }
1.1844 + iProcessQ.Append(pic);
1.1845 + #ifdef _DUMP_YUV_FRAMES
1.1846 + captureYuv(pic);
1.1847 + #endif
1.1848 + iSessionManager->PostPicture(iSurfaceId, GetID(pic), iInfo().iBuffers, ETrue);
1.1849 + iCurrentPlaybackPosition = pic->iTimestamp;
1.1850 + if(!iFirstPictureUpdated)
1.1851 + {
1.1852 + iFirstPictureUpdated = ETrue;
1.1853 + if(!iSurfaceCreatedEventPublished)
1.1854 + {
1.1855 + PublishSurfaceCreated();
1.1856 + }
1.1857 + }
1.1858 + } // end of postit
1.1859 + break;
1.1860 + case ESkipIt:
1.1861 + {
1.1862 + RemoveFromQ();
1.1863 + ReleasePicture(pic);
1.1864 + PicturesSkipped();
1.1865 + }
1.1866 + break;
1.1867 + } // end of switch
1.1868 +
1.1869 + // get the next picture
1.1870 + pic = PeekQ();
1.1871 + } // end of while
1.1872 +
1.1873 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AttemptToPost --"), this);
1.1874 + return err;
1.1875 +}
1.1876 +
1.1877 +TInt CNGAPostProcHwDevice::IsTimeToPost(TVideoPicture* frame, TInt64& delta)
1.1878 +{
1.1879 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost ++"), this);
1.1880 +
1.1881 + if (!frame)
1.1882 + {
1.1883 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost FAILED: Invalid frame ptr."), this);
1.1884 + return KErrGeneral;
1.1885 + }
1.1886 +
1.1887 + TInt resp = EPostIt;
1.1888 + // Frame presentation time
1.1889 + TInt64 uPresTime = frame->iTimestamp.Int64();
1.1890 +
1.1891 + // Check if this is an out of order frame in case of forward playback
1.1892 + if((iCurrentPlaybackPosition.Int64() > uPresTime) && (iPlayRate > 0))
1.1893 + {
1.1894 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost : Out of order frame (forward playback) Tfm=%d"), this,(TInt)uPresTime);
1.1895 + resp = ESkipIt; //drop
1.1896 + } // Check if this is an out of order frame in case of backward playback
1.1897 + else if((iCurrentPlaybackPosition.Int64() < uPresTime) && (iPlayRate < 0))
1.1898 + {
1.1899 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost : Out of order frame (backward playback) Tfm=%d"), this,(TInt)uPresTime);
1.1900 + resp = ESkipIt; //drop
1.1901 + }
1.1902 + else if (iClockSource)
1.1903 + {
1.1904 + // The time to sync with.
1.1905 + TInt64 uSyncTime = iClockSource->Time().Int64();
1.1906 +
1.1907 + delta = uPresTime - uSyncTime;
1.1908 + if (( delta > KRenderAhead ) && (iPlayRate > 0)) // Delay condition not checked for
1.1909 + { // backward playback
1.1910 + resp = EDelayIt; //wait
1.1911 + }
1.1912 + else if ( (delta < (-KMaxRenderDelay) && (iPlayRate > 0))
1.1913 + || ((delta > KMaxRenderDelay) && (iPlayRate < 0)))
1.1914 + {
1.1915 + resp = ESkipIt; //drop
1.1916 + }
1.1917 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost .. Tfm=%d, Tcs=%d, delta=%d"), this, (TInt)uPresTime, (TInt)uSyncTime, (TInt)delta);
1.1918 + }
1.1919 +
1.1920 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost -- %d BufID = %d"), this, resp, GetID(frame));
1.1921 + return resp;
1.1922 +}
1.1923 +
1.1924 +void CNGAPostProcHwDevice::ReleaseInputQ()
1.1925 +{
1.1926 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputQ ++ Q = %d"), this, iInputQ.Count());
1.1927 + while (iInputQ.Count()>0)
1.1928 + {
1.1929 + ReleasePicture(iInputQ[0]);
1.1930 + iInputQ.Remove(0);
1.1931 + }
1.1932 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputQ --"), this);
1.1933 +}
1.1934 +
1.1935 +void CNGAPostProcHwDevice::ReleaseProcessQ()
1.1936 +{
1.1937 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseProcessQ ++ Q = %d"), this, iProcessQ.Count() );
1.1938 + TVideoPicture* pic = NULL;
1.1939 +
1.1940 + while (iProcessQ.Count()>0)
1.1941 + {
1.1942 + pic = iProcessQ[0];
1.1943 + iProcessQ.Remove(0);
1.1944 + ReturnPicToDecoder(pic);
1.1945 + }
1.1946 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseProcessQ --"), this);
1.1947 +}
1.1948 +
1.1949 +void CNGAPostProcHwDevice::ReleasePicture(TVideoPicture *pic)
1.1950 +{
1.1951 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleasePicture ++"), this);
1.1952 + if (pic == NULL)
1.1953 + {
1.1954 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputPicture FAILED: Invalid pic ptr."), this);
1.1955 + return;
1.1956 + }
1.1957 +
1.1958 + if (iInputDecoderDevice)
1.1959 + {
1.1960 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputPicture .. before return picture. 2"), this);
1.1961 + iInputDecoderDevice->ReturnPicture(pic);
1.1962 + }
1.1963 + if (iVBMEnabled)
1.1964 + {
1.1965 + iVBMBufferQ.Append(pic);
1.1966 +
1.1967 + if ( !iIsInputEnded && iPPState != EStopped )
1.1968 + {
1.1969 + iVBMObserver->MmvbmoNewBuffers();
1.1970 + }
1.1971 + }
1.1972 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleasePicture --"), this);
1.1973 +}
1.1974 +
1.1975 +void CNGAPostProcHwDevice::PublishSurfaceCreated()
1.1976 +{
1.1977 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PublishSurfaceCreated ++"), this);
1.1978 + if(iVideoSurfaceObserver)
1.1979 + {
1.1980 + iVideoSurfaceObserver->MmvsoSurfaceCreated();
1.1981 + iSurfaceCreatedEventPublished = ETrue;
1.1982 + }
1.1983 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PublishSurfaceCreated --"), this);
1.1984 +}
1.1985 +
1.1986 +TInt CNGAPostProcHwDevice::SetupSurface(const TSize& aSize)
1.1987 +{
1.1988 + TInt err = KErrNone;
1.1989 + if(iVBMEnabled && iVBMObserver)
1.1990 + {
1.1991 + SetSurfaceAttributes(aSize, KMaxVBMBuffers);
1.1992 + iVBMBufferOptions.iNumInputBuffers = KMaxVBMBuffers;
1.1993 +
1.1994 + //Decoder needs the buffer size to fit in yuv422 decoded output.
1.1995 + iVBMBufferOptions.iBufferSize = aSize;
1.1996 +
1.1997 + err = iSurfaceHandler->CreateSurface(iAttributes, iSurfaceId);
1.1998 + if (err != KErrNone)
1.1999 + {
1.2000 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create Surface %d"), this, err);
1.2001 + return err;
1.2002 + }
1.2003 + err = iSurfaceHandler->MapSurface(iSurfaceId, iChunk);
1.2004 + if (err != KErrNone)
1.2005 + {
1.2006 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to map Surface %d"), this, err);
1.2007 + iSurfaceHandler->DestroySurface(iSurfaceId);
1.2008 + iSurfaceId = TSurfaceId::CreateNullId();
1.2009 + return err;
1.2010 + }
1.2011 + err = iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo);
1.2012 + if (err != KErrNone)
1.2013 + {
1.2014 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to get Surface info %d"), this, err);
1.2015 + iSurfaceHandler->DestroySurface(iSurfaceId);
1.2016 + iSurfaceId = TSurfaceId::CreateNullId();
1.2017 + return err;
1.2018 + }
1.2019 + TRAP(err, CreateVBMBuffersL());
1.2020 + if (err != KErrNone)
1.2021 + {
1.2022 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create VBM buffer %d"), this, err);
1.2023 + iSurfaceHandler->DestroySurface(iSurfaceId);
1.2024 + iSurfaceId = TSurfaceId::CreateNullId();
1.2025 + return err;
1.2026 + }
1.2027 + err = AddHints();
1.2028 + if (err != KErrNone)
1.2029 + {
1.2030 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to AddHints %d"), this, err);
1.2031 + return err;
1.2032 + }
1.2033 + err = RegisterSurface(iSurfaceId);
1.2034 + if (err != KErrNone)
1.2035 + {
1.2036 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to RegisterSurface %d"), this, err);
1.2037 + iSurfaceHandler->DestroySurface(iSurfaceId);
1.2038 + iSurfaceId = TSurfaceId::CreateNullId();
1.2039 + return err;
1.2040 + }
1.2041 +
1.2042 + }
1.2043 + return err;
1.2044 +}
1.2045 +
1.2046 +void CNGAPostProcHwDevice::SetSurfaceAttributes(const TSize& aSize, TInt aNumBuf)
1.2047 +{
1.2048 + iAttributes().iSize = aSize; // size of the video frame
1.2049 + iAttributes().iBuffers = aNumBuf;
1.2050 +
1.2051 + /* The stride needs to be calculated for the surface manager to know
1.2052 + how much memory to allocate */
1.2053 +
1.2054 + if(iAttributes().iPixelFormat == EUidPixelFormatYUV_420Planar)
1.2055 + {
1.2056 + iAttributes().iStride = aSize.iWidth * 3/2;
1.2057 + iVideoFrameBufSize = aSize.iWidth * aSize.iHeight * 3/2;
1.2058 + }
1.2059 + else
1.2060 + {
1.2061 + iAttributes().iStride = aSize.iWidth * 2;
1.2062 + iVideoFrameBufSize = aSize.iWidth * aSize.iHeight * 2;
1.2063 + }
1.2064 +
1.2065 + if(iIsColorConversionNeeded)
1.2066 + {
1.2067 + iAttributes().iBuffers = aNumBuf + KColorConversionBuffers;
1.2068 + }
1.2069 + else
1.2070 + {
1.2071 + iAttributes().iBuffers = aNumBuf;
1.2072 + }
1.2073 +
1.2074 + iAttributes().iOffsetToFirstBuffer = 0;
1.2075 + iAttributes().iAlignment = 4;
1.2076 + iAttributes().iContiguous = ETrue;
1.2077 + iAttributes().iHintCount = 0;
1.2078 + iAttributes().iMappable = ETrue;
1.2079 +}
1.2080 +
1.2081 +TInt CNGAPostProcHwDevice::GetID(TVideoPicture *aPicture)
1.2082 +{
1.2083 + if (iUsingExternalSurface)
1.2084 + {
1.2085 + return GetExternalBufferID(aPicture);
1.2086 + }
1.2087 + else
1.2088 + {
1.2089 + TUint8* aPtr = (TUint8*) aPicture->iData.iRawData->Ptr();
1.2090 + return( (TInt) ((aPtr - iChunk.Base() - iAttributes().iOffsetToFirstBuffer) /
1.2091 + (iVideoFrameBufSize )));
1.2092 + }
1.2093 +}
1.2094 +
1.2095 +TInt CNGAPostProcHwDevice::GetExternalBufferID(TVideoPicture *aPicture)
1.2096 +{
1.2097 + // currently type cast the pointer as buffer ID.
1.2098 + // FIXME once the new data structure is available.
1.2099 + return( (TInt) aPicture->iData.iRawData->Ptr());
1.2100 +}
1.2101 +
1.2102 +TInt CNGAPostProcHwDevice::RegisterSurface(const TSurfaceId& aSurfaceId)
1.2103 +{
1.2104 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:RegisterSurface(): RegisterSurface ID = 0x%x"), this, aSurfaceId);
1.2105 + TInt err = KErrNone;
1.2106 + TInt numScreens = iWsSession.NumberOfScreens();
1.2107 + for(TInt i=0; (i < numScreens && err == KErrNone); i++)
1.2108 + {
1.2109 + err = iWsSession.RegisterSurface(i, aSurfaceId);
1.2110 + }
1.2111 + return(err);
1.2112 +}
1.2113 +
1.2114 +TInt CNGAPostProcHwDevice::IsGceReady()
1.2115 +{
1.2116 + if(iProcessQ.Count() >= KMaxBuffersGceCanHold)
1.2117 + {
1.2118 + return EFalse;
1.2119 + }
1.2120 + return ETrue;
1.2121 +}
1.2122 +
1.2123 +void CNGAPostProcHwDevice::SetTimer(TInt64 aDelta)
1.2124 +{
1.2125 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetTimer .. aDelta=%d"), this, (TInt)aDelta);
1.2126 + if(aDelta <= KRenderAhead)
1.2127 + {
1.2128 + if(aDelta < 0)
1.2129 + {
1.2130 + iPostingTimer->After(aDelta * -1);
1.2131 + }
1.2132 + else
1.2133 + {
1.2134 + iPostingTimer->After((aDelta - KRenderAhead) * -1);
1.2135 + }
1.2136 + }
1.2137 + else
1.2138 + {
1.2139 + iPostingTimer->After(aDelta - KRenderAhead - KPostingOfset);
1.2140 + }
1.2141 +}
1.2142 +//
1.2143 +// Convert YUV420 to YUV422InterLeaved.
1.2144 +//
1.2145 +TInt CNGAPostProcHwDevice::ConvertPostProcBuffer(TVideoPicture* pSrc, TVideoPicture* pDest)
1.2146 +{
1.2147 + PP_DEBUG(_L("CMdfPostingSurfaceProxy::ConvertPostProcBuffer ++"));
1.2148 + TInt err = KErrNone;
1.2149 + if (!pDest && !pSrc)
1.2150 + {
1.2151 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ConvertPostProcBuffer FAILED: Invalid pic pSrc %x pDest %x."), this, pSrc, pDest);
1.2152 + return KErrArgument;
1.2153 + }
1.2154 +
1.2155 + // --- Prepare wrappers ---
1.2156 + tBaseVideoFrame tFrame420, tFrame422;
1.2157 + TInt frameSize = pSrc->iData.iDataSize.iWidth * pSrc->iData.iDataSize.iHeight;
1.2158 +
1.2159 + PP_DEBUG(_L("CMdfPostingSurfaceProxy::ConvertPostProcBuffer .. w=%d, h=%d"), pSrc->iData.iDataSize.iWidth, pSrc->iData.iDataSize.iHeight);
1.2160 +
1.2161 + tFrame420.width = pSrc->iData.iDataSize.iWidth;
1.2162 + tFrame420.height= pSrc->iData.iDataSize.iHeight;
1.2163 + tFrame420.lum = (TUint8*)pSrc->iData.iRawData->Ptr();
1.2164 + tFrame420.cb = (TUint8*)tFrame420.lum + frameSize;
1.2165 + tFrame420.cr = (TUint8*)tFrame420.lum + (frameSize*5)/4;
1.2166 +
1.2167 + tFrame422.width = pSrc->iData.iDataSize.iWidth;
1.2168 + tFrame422.height= pSrc->iData.iDataSize.iHeight;
1.2169 + tFrame422.lum = (TUint8*)pDest->iData.iRawData->Ptr();
1.2170 + tFrame422.cb = 0;
1.2171 + tFrame422.cr = 0;
1.2172 +
1.2173 + // --- Convertion to posting buffer ---
1.2174 + TInt stride = pSrc->iData.iDataSize.iWidth * 2;
1.2175 + EBufferLayout422 layout = YUV422INT_BE;
1.2176 +
1.2177 + err = gColorConvYUVtoYUV422Int(&tFrame420, &tFrame422, layout, stride);
1.2178 + if(err != KErrNone)
1.2179 + {
1.2180 + PP_DEBUG(_L("CNGAPostProcHwDevice::ConvertPostProcBuffer .. err= %d."), err);
1.2181 + }
1.2182 + return err;
1.2183 +}
1.2184 +
1.2185 +void CNGAPostProcHwDevice::AddPictureToVBMQ(TVideoPicture *pic)
1.2186 +{
1.2187 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddPictureToVBMQ ++"), this);
1.2188 + iVBMBufferQ.Append(pic);
1.2189 +
1.2190 + if ( !iIsInputEnded && iPPState != EStopped )
1.2191 + {
1.2192 + iVBMObserver->MmvbmoNewBuffers();
1.2193 + }
1.2194 +
1.2195 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddPictureToVBMQ --"), this);
1.2196 +}
1.2197 +
1.2198 +void CNGAPostProcHwDevice::AddPictureToColorConversionQ(TVideoPicture *pic)
1.2199 +{
1.2200 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddPictureToColorConversionQ ++"), this);
1.2201 + iColorConversionQ.Append(pic);
1.2202 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddPictureToColorConversionQ --"), this);
1.2203 +}
1.2204 +
1.2205 +#ifdef _DUMP_YUV_FRAMES
1.2206 +void CNGAPostProcHwDevice::captureYuv(TVideoPicture* aPicture)
1.2207 +{
1.2208 + char buf[128];
1.2209 + sprintf(buf, "c:\\fb%d.yuv", count++);
1.2210 + FILE *fp = ::fopen(buf, "w");
1.2211 + TInt size = aPicture->iData.iRawData->Size();
1.2212 + //{FILE* f1 = fopen(MY_LOG_FILE_NAME, "a+"));if(f1){fprintf(f1, "Size %d \n"), size );fclose(f1); }}
1.2213 +
1.2214 + ::fwrite(aPicture->iData.iRawData->Ptr(), 1, size, fp);
1.2215 + ::fclose(fp);
1.2216 +}
1.2217 +#endif
1.2218 +
1.2219 +void CNGAPostProcHwDevice::ResetCountingBuffer()
1.2220 +{
1.2221 + memset(iSkippedFramesCountingBuffer,0,sizeof(iSkippedFramesCountingBuffer));
1.2222 + iSkippedFramesInLast64Frames = 0;
1.2223 + iCurrentPosInFramesCountingBuffer = 0;
1.2224 +}
1.2225 +
1.2226 +void CNGAPostProcHwDevice::PicturesSkipped()
1.2227 +{
1.2228 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PicturesSkipped ++"), this);
1.2229 + iPictureCounters.iPicturesSkipped++;
1.2230 + if (!iKeyFrameMode && iPlayRate>KDefPlayRate)
1.2231 + {
1.2232 + if (iSkippedFramesCountingBuffer[iCurrentPosInFramesCountingBuffer]==0)
1.2233 + {
1.2234 + iSkippedFramesCountingBuffer[iCurrentPosInFramesCountingBuffer] = 1;
1.2235 + iSkippedFramesInLast64Frames++;
1.2236 + if (iSkippedFramesInLast64Frames>KMaxAllowedSkipInNFrames && iFPObserver )
1.2237 + {
1.2238 + iFPObserver->MmvproKeyFrameModeRequest();
1.2239 + iKeyFrameMode=ETrue;
1.2240 + ResetCountingBuffer();
1.2241 + }
1.2242 + }
1.2243 + iCurrentPosInFramesCountingBuffer = ++iCurrentPosInFramesCountingBuffer%64;
1.2244 + }
1.2245 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PicturesSkipped --"), this);
1.2246 +}
1.2247 +
1.2248 +TVideoPicture* CNGAPostProcHwDevice::DoColorConvert(TVideoPicture* aPicture)
1.2249 +{
1.2250 + TVideoPicture *pOutPicture = aPicture;
1.2251 +
1.2252 + if(iColorConversionQ.Count())
1.2253 + {
1.2254 + pOutPicture = iColorConversionQ[0];
1.2255 + iColorConversionQ.Remove(0);
1.2256 + ConvertPostProcBuffer(aPicture, pOutPicture);
1.2257 + pOutPicture->iTimestamp = aPicture->iTimestamp;
1.2258 + ReleasePicture(aPicture);
1.2259 + }
1.2260 + else
1.2261 + {
1.2262 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: color conversion"), this);
1.2263 + }
1.2264 +
1.2265 + return pOutPicture;
1.2266 +}
1.2267 +
1.2268 +TInt CNGAPostProcHwDevice::AddToQ(TVideoPicture* aPicture)
1.2269 +{
1.2270 + TVideoPicture* pic = aPicture;
1.2271 + TInt pos = -1;
1.2272 + if(iInputQ.Count() == 0)
1.2273 + {
1.2274 + iInputQ.Append(pic);
1.2275 + }
1.2276 + else
1.2277 + {
1.2278 + pos = iInputQ.Count()-1;
1.2279 + for(; pos >= 0; pos--)
1.2280 + {
1.2281 + if(pic->iTimestamp.Int64() > iInputQ[pos]->iTimestamp.Int64())
1.2282 + {
1.2283 + break;
1.2284 + }
1.2285 + }
1.2286 + if(iInputQ.Count() == pos+1)
1.2287 + {
1.2288 + iInputQ.Append(pic);
1.2289 + }
1.2290 + else
1.2291 + {
1.2292 + iInputQ.Insert(pic, pos+1);
1.2293 + }
1.2294 + }
1.2295 + return pos+1;
1.2296 +}
1.2297 +
1.2298 +void CNGAPostProcHwDevice::RemoveFromQ()
1.2299 +{
1.2300 + if(iInputQ.Count())
1.2301 + {
1.2302 + if(iPlayRate > 0)
1.2303 + {
1.2304 + iInputQ.Remove(0);
1.2305 + }
1.2306 + else
1.2307 + {
1.2308 + iInputQ.Remove(iInputQ.Count()-1);
1.2309 + }
1.2310 + }
1.2311 +}
1.2312 +
1.2313 +TVideoPicture* CNGAPostProcHwDevice::PeekQ()
1.2314 +{
1.2315 + TVideoPicture *pic = NULL;
1.2316 + if(iInputQ.Count())
1.2317 + {
1.2318 + if(iPlayRate > 0)
1.2319 + {
1.2320 + pic = iInputQ[0];
1.2321 + }
1.2322 + else
1.2323 + {
1.2324 + pic = iInputQ[iInputQ.Count()-1];
1.2325 + }
1.2326 + }
1.2327 + return pic;
1.2328 +}
1.2329 +
1.2330 +TInt CNGAPostProcHwDevice::AddHints()
1.2331 +{
1.2332 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints iSurfaceMask 0x%08x ++"), this, iSurfaceMask);
1.2333 + TInt err = KErrNone;
1.2334 + iHint.Set(iSurfaceKey,iSurfaceMask,ETrue);
1.2335 + err = iSurfaceHandler->AddSurfaceHint(iSurfaceId,iHint);
1.2336 + if(err == KErrAlreadyExists)
1.2337 + {
1.2338 + err = iSurfaceHandler->SetSurfaceHint(iSurfaceId,iHint);
1.2339 + }
1.2340 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints. err = %d --"), this,err);
1.2341 + iHint.iKey.iUid = surfaceHints::KSurfaceContent;
1.2342 + iHint.iValue = surfaceHints::EVideoPlayback;
1.2343 + iHint.iMutable = ETrue;
1.2344 + err = iSurfaceHandler->AddSurfaceHint(iSurfaceId,iHint);
1.2345 + if(err == KErrAlreadyExists)
1.2346 + {
1.2347 + err = iSurfaceHandler->SetSurfaceHint(iSurfaceId,iHint);
1.2348 + }
1.2349 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints. err = %d --"), this,err);
1.2350 + if(iUsingExternalSurface)
1.2351 + {
1.2352 + iHint.iKey.iUid = surfaceHints::KSurfaceCharacteristics;
1.2353 + iHint.iValue = surfaceHints::ENotPersistable;
1.2354 + iHint.iMutable = ETrue;
1.2355 + err = iSurfaceHandler->AddSurfaceHint(iSurfaceId,iHint);
1.2356 + if(err == KErrAlreadyExists)
1.2357 + {
1.2358 + err = iSurfaceHandler->SetSurfaceHint(iSurfaceId,iHint);
1.2359 + }
1.2360 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints. err = %d --"), this,err);
1.2361 + }
1.2362 + return err;
1.2363 +}
1.2364 +
1.2365 +TInt CNGAPostProcHwDevice::ColorConvert(tBaseVideoFrame* aInputFrame, TUint8* aDestPtr, tWndParam* aInputCropWindow, tWndParam* aOutputCropWindow)
1.2366 +{
1.2367 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ColorConvert ++"), this);
1.2368 + __ASSERT_ALWAYS(aDestPtr, User::Invariant());
1.2369 + TInt lError = E_SUCCESS;
1.2370 + TInt err = KErrNone;
1.2371 +
1.2372 + err = SetSourceFormat();
1.2373 + if(err == KErrNone)
1.2374 + {
1.2375 + err = SetSourceRange();
1.2376 + if(err == KErrNone)
1.2377 + {
1.2378 +
1.2379 + lError = Emz_VDec_gColorConv_YUVtoRGB(aInputFrame,aDestPtr,
1.2380 + aInputCropWindow, aOutputCropWindow, iSourceFormat,
1.2381 + EBitmapColor16MU, iSourceRange);
1.2382 +
1.2383 + if(lError)
1.2384 + {
1.2385 + if(lError == E_OUT_OF_MEMORY)
1.2386 + {
1.2387 + err = KErrNoMemory;
1.2388 + }
1.2389 + else if(lError == E_FAILURE)
1.2390 + {
1.2391 + err = KErrNotSupported;
1.2392 + }
1.2393 + else
1.2394 + {
1.2395 + err = KErrGeneral;
1.2396 + }
1.2397 + }
1.2398 + }
1.2399 + }
1.2400 +
1.2401 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ColorConvert --"), this);
1.2402 + return err;
1.2403 +}
1.2404 +
1.2405 +TInt CNGAPostProcHwDevice::SetSourceFormat()
1.2406 +{
1.2407 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceFormatL ++"), this);
1.2408 + TInt err = KErrNone;
1.2409 + switch (iVideoFormat.iYuvFormat.iPattern)
1.2410 + {
1.2411 + case EYuv420Chroma1:
1.2412 + iSourceFormat = EYuv420Chroma1_Planar;
1.2413 + break;
1.2414 + case EYuv420Chroma2:
1.2415 + iSourceFormat = EYuv420Chroma2_Planar;
1.2416 + break;
1.2417 + case EYuv420Chroma3:
1.2418 + iSourceFormat = EYuv420Chroma3_Planar;
1.2419 + break;
1.2420 + case EYuv422Chroma1:
1.2421 + if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedLE)
1.2422 + iSourceFormat = EYuv422Chroma1_LE;
1.2423 + else if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedBE )
1.2424 + iSourceFormat = EYuv422Chroma1_BE;
1.2425 + else
1.2426 + err = KErrArgument;
1.2427 + break;
1.2428 + case EYuv422Chroma2:
1.2429 + if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedLE)
1.2430 + iSourceFormat = EYuv422Chroma2_LE;
1.2431 + else if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedBE )
1.2432 + iSourceFormat = EYuv422Chroma2_BE;
1.2433 + else
1.2434 + err = KErrArgument;
1.2435 + break;
1.2436 + default:
1.2437 + err = KErrNotSupported;
1.2438 + }
1.2439 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceFormatL --"), this);
1.2440 + return err;
1.2441 +}
1.2442 +
1.2443 +
1.2444 +TInt CNGAPostProcHwDevice::SetSourceRange()
1.2445 +{
1.2446 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceRangeL ++"), this);
1.2447 + TInt err = KErrNone;
1.2448 + switch (iVideoFormat.iYuvFormat.iCoefficients)
1.2449 + {
1.2450 + case EYuvBt601Range0:
1.2451 + iSourceRange = EITU601_5_REDUCEDRANGE;
1.2452 + break;
1.2453 + case EYuvBt601Range1:
1.2454 + iSourceRange = EITU601_5_FULLRANGE;
1.2455 + break;
1.2456 + case EYuvBt709Range0:
1.2457 + iSourceRange = EB709_REDUCEDRANGE;
1.2458 + break;
1.2459 + case EYuvBt709Range1:
1.2460 + iSourceRange = EB709_FULLRANGE;
1.2461 + break;
1.2462 + default:
1.2463 + err = KErrNotSupported;
1.2464 + }
1.2465 + PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceRangeL --"), this);
1.2466 + return err;
1.2467 +}
1.2468 +
1.2469 +CNGAPostProcTimer::CNGAPostProcTimer( CNGAPostProcHwDevice& aParent )
1.2470 +:CTimer(EPriorityHigh),iParent(aParent)
1.2471 +{
1.2472 + CActiveScheduler::Add(this);
1.2473 +}
1.2474 +
1.2475 +CNGAPostProcTimer::~CNGAPostProcTimer()
1.2476 +{
1.2477 + PP_DEBUG(_L("CNGAPostProcTimer[%x]:~CNGAPostProcTimer ++"), this);
1.2478 + Cancel();
1.2479 + PP_DEBUG(_L("CNGAPostProcTimer[%x]:~CNGAPostProcTimer --"), this);
1.2480 +}
1.2481 +
1.2482 +CNGAPostProcTimer* CNGAPostProcTimer::NewL( CNGAPostProcHwDevice& aParent )
1.2483 +{
1.2484 + CNGAPostProcTimer* self = new (ELeave)CNGAPostProcTimer(aParent);
1.2485 + CleanupStack::PushL( self );
1.2486 + self->ConstructL();
1.2487 + CleanupStack::Pop( self );
1.2488 + return self;
1.2489 +}
1.2490 +
1.2491 +void CNGAPostProcTimer::ConstructL()
1.2492 +{
1.2493 + CTimer::ConstructL();
1.2494 +}
1.2495 +
1.2496 +void CNGAPostProcTimer::RunL()
1.2497 +{
1.2498 + PP_DEBUG(_L("CNGAPostProcTimer[%x]:RunL ++"), this);
1.2499 + if (iStatus ==KErrCancel)
1.2500 + {
1.2501 + PP_DEBUG(_L("CNGAPostProcNotifier[%x]:CNGAPostProcNotifier:RunL State canceled"), this);
1.2502 + return;
1.2503 + }
1.2504 + iParent.AttemptToPost();
1.2505 + PP_DEBUG(_L("CNGAPostProcTimer[%x]:RunL --"), this);
1.2506 +}
1.2507 +