os/mm/mdfdevvideoextensions/nga_mdf_postprocessor_shai/src/NGAPostProcHwDevice.cpp
Update contrib.
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include "NGAPostProcHwDevice.h"
20 #include "NGAPostProcSessionManager.h"
21 #include "NGAPostProcSurfaceHandler.h"
23 //currently this uid only used if not under WINSCW environment since the only hw to use is bridge
24 #define EStUidPixelFormatYUV_420MB 0x2001FBC1
25 // post-processor info
26 const TUid KUidVideoPostProcHwDevice = {KUidNGAPostProcHwDeviceImplUid};
27 _LIT(KManufacturer, "Nokia Inc.");
28 _LIT(KIdentifier, "Nokia S60 Video Post Processor Hardware Device Plugin");
31 const TInt KMaxVBMBuffers = 4;
32 const TInt KMinVBMInputWidth = 32;
33 const TInt KMinVBMInputHeight = 32;
34 const TInt KMaxVBMInputWidth = 1280;
35 const TInt KMaxVBMInputHeight = 720;
36 const TInt KRenderAhead = 50000;
37 const TInt KMaxRenderDelay = 50000;
38 const TInt KPostingOfset = 0;
39 const TInt KColorConversionBuffers = 3;
40 const TInt KMaxBuffersGceCanHold = 3;
41 const TInt KDefPlayRate = 100;
42 const TInt KMaxAllowedSkipInNFrames = 40;
48 int32 gColorConvYUVtoYUV422Int (tBaseVideoFrame *yuv420Frame, tBaseVideoFrame* yuv422Frame,
49 uint8 outClrFmt, int16 stride);
51 int32 Emz_VDec_gColorConv_YUVtoRGB (
52 tBaseVideoFrame *srcImage, uint8 *dstImage, tWndParam *srcWindow,
53 tWndParam *dstWindow, uint8 srcImageFormat, uint8 dstImageFormat,
54 uint8 colorConvScheme);
60 //**************************************************
62 CMMFVideoPostProcHwDevice* CNGAPostProcHwDevice::NewL()
64 PP_DEBUG(_L("CNGAPostProcHwDevice::NewL() ++"));
66 CNGAPostProcHwDevice* self = new (ELeave) CNGAPostProcHwDevice;
67 CleanupStack::PushL(self);
71 PP_DEBUG(_L("CNGAPostProcHwDevice::NewL() --"));
72 return (CMMFVideoPostProcHwDevice*)self;
75 void CNGAPostProcHwDevice::ConstructL()
77 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::ConstructL() ++"), this);
79 // support for VBM buffer interface
80 iVBMBufferOptions.iNumInputBuffers = KMaxVBMBuffers;
81 iVBMBufferOptions.iBufferSize = TSize(KMaxVBMInputWidth, KMaxVBMInputHeight);
82 iPostingTimer = CNGAPostProcTimer::NewL(*this);
83 User::LeaveIfError(iWsSession.Connect());
85 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::ConstructL() --"), this);
88 CNGAPostProcHwDevice::CNGAPostProcHwDevice()
90 iInputDecoderDevice(NULL),
91 iCurrentPlaybackPosition(TTimeIntervalMicroSeconds(0)),
92 iPPState(EInitializing),
93 iSurfaceHandler(NULL),
94 iSessionManager(NULL),
95 iIsInputEnded(EFalse),
97 iFirstPictureUpdated(EFalse),
98 iUsingExternalSurface(EFalse),
99 iIsColorConversionNeeded(EFalse),
100 iSurfaceCreatedEventPublished(EFalse),
101 iOverflowPictureCounter(0),
102 iVideoFrameBufSize(0),
103 iResourceLost(EFalse),
105 iRedrawSurfaceInUse(EFalse),
109 iSurfaceMask(surfaceHints::EAllowAllExternals),
110 iSurfaceKey(TUid::Uid(surfaceHints::KSurfaceProtection)),
111 iVideoSurfaceObserver(NULL),
115 iAspectRatioDenom(1),
117 iPlayRate(KDefPlayRate),
118 iKeyFrameMode(EFalse),
120 iIsExternalChunk(EFalse)
122 iSurfaceId = TSurfaceId::CreateNullId();
124 #if defined __WINSCW__
125 iAttributes().iPixelFormat = EUidPixelFormatYUV_422Interleaved;
127 iAttributes().iPixelFormat = (TUidPixelFormat) EStUidPixelFormatYUV_420MB;
131 CNGAPostProcHwDevice::~CNGAPostProcHwDevice()
133 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::~CNGAPostProcHwDevice() ++"), this);
136 iSessionManager->CancelNotifiers();
137 delete iSessionManager;
138 iSessionManager = NULL;
141 while (iSupportedInputFormats.Count()>0)
143 iSupportedInputFormats.Remove(0);
146 while (iProcessQ.Count()>0)
153 iPostingTimer->Cancel();
154 delete iPostingTimer;
155 iPostingTimer = NULL;
158 while (iVBMBufferReferenceQ.Count()>0)
160 TVideoPicture* pic = iVBMBufferReferenceQ[0];
161 iVBMBufferReferenceQ.Remove(0);
162 if (iColorConversionQ.Count()>0)
164 iColorConversionQ.Remove(0);
167 if (pic->iHeader) delete pic->iHeader;
168 delete pic->iData.iRawData;
172 iSupportedInputFormats.Reset();
173 iSupportedInputFormats.Close();
175 iVBMBufferReferenceQ.Reset();
176 iVBMBufferReferenceQ.Close();
178 iColorConversionQ.Reset();
179 iColorConversionQ.Close();
192 if(!iSurfaceId.IsNull())
194 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::UnregisterSurface"), this);
195 TInt numScreens = iWsSession.NumberOfScreens();
196 for(TInt i=0;i < numScreens;i++)
198 iWsSession.UnregisterSurface(i, iSurfaceId);
201 TInt err = iSurfaceHandler->DestroySurface(iSurfaceId);
203 delete iSurfaceHandler;
204 iSurfaceHandler = NULL;
208 if(!iIsExternalChunk)
213 RDebug::Printf("------ Statistics of Post Processor ------");
214 RDebug::Printf(" Pictures Received : %d", iPictureCounters.iTotalPictures);
215 RDebug::Printf(" Pictures Displayed: %d", iPictureCounters.iPicturesDisplayed);
216 RDebug::Printf(" Pictures Skipped : %d", iPictureCounters.iPicturesSkipped);
217 RDebug::Printf(" Pictures overflow : %d", iOverflowPictureCounter);
218 RDebug::Printf("------------------------------------------");
220 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:~() --"), this);
223 void CNGAPostProcHwDevice::SetInputFormatL(const TUncompressedVideoFormat& aFormat)
225 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputFormatL() Pattern= %x ++"), this, aFormat.iYuvFormat.iPattern);
226 if (iPPState != EInitializing)
228 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputFormatL() FAILED: Unexpected state"), this);
229 User::Leave(KErrNotReady);
232 iVideoFormat = aFormat;
233 if( ((iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma1) ||
234 (iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma2) ||
235 (iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma3) ))
237 iVideoFormat.iYuvFormat.iCoefficients = EYuvBt709Range1;
238 iVideoFormat.iYuvFormat.iPattern = EYuv422Chroma1;
239 iVideoFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedBE;
241 #if defined __WINSCW__
242 iIsColorConversionNeeded = ETrue;
244 iAttributes().iPixelFormat = (TUidPixelFormat) EStUidPixelFormatYUV_420MB;
248 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputFormatL() WARNING: -- Not Found!"), this);
252 void CNGAPostProcHwDevice::SetInputDevice(CMMFVideoDecodeHwDevice* aDevice)
254 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputDevice() ++"), this);
256 if (iPPState != EInitializing)
258 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputDevice() FAILED: unexpected state"), this);
262 iInputDecoderDevice = aDevice;
264 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputDevice() --"), this);
267 void CNGAPostProcHwDevice::GetOutputFormatListL(RArray<TUncompressedVideoFormat>& )
269 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetOutputFormatListL() ++"), this);
272 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetOutputFormatListL() --"), this);
275 void CNGAPostProcHwDevice::SetOutputFormatL(const TUncompressedVideoFormat& )
277 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetOutputFormatL() ++"), this);
279 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetOutputFormatL() --"), this);
282 void CNGAPostProcHwDevice::SetClockSource(MMMFClockSource* aClock)
284 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetClockSource() ++"), this);
286 if (iPPState != EInitializing)
288 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetClockSource() FAILED: Unexpected state"), this);
291 iClockSource = aClock;
293 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetClockSource() --"), this);
296 void CNGAPostProcHwDevice::SetVideoDestScreenL(TBool /*aScreen*/)
298 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetVideoDestScreenL() ++"), this);
300 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetVideoDestScreenL() --"), this);
303 void CNGAPostProcHwDevice::SetProxy(MMMFDevVideoPlayProxy& aProxy)
305 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetProxy() ++"), this);
307 if (iPPState != EInitializing)
309 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetProxy() FAILED: Unexpected state"), this);
315 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetProxy() --"), this);
318 void CNGAPostProcHwDevice::Initialize()
320 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize ++"));
323 if (iPPState != EInitializing)
325 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize() FAILED: Unexpected state"), this);
328 iProxy->MdvppInitializeComplete(this, KErrNotReady);
332 if (!iSurfaceHandler)
334 TRAP(err, iSurfaceHandler = CNGAPostProcSurfaceHandler::NewL());
337 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create SurfaceHandler."), this);
340 iProxy->MdvppInitializeComplete(this, err);
345 if (!iSessionManager)
347 TRAP(err, iSessionManager = CNGAPostProcSessionManager::NewL());
350 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create SessionManager."), this);
353 iProxy->MdvppInitializeComplete(this, err);
357 iSessionManager->SetObserver(*this);
360 if (iInputDecoderDevice)
362 MMmfVideoResourceHandler* handler = NULL;
363 handler = (MMmfVideoResourceHandler*)iInputDecoderDevice->CustomInterface(KUidMmfVideoResourceManagement);
366 handler->MmvrhSetObserver((MMmfVideoResourceObserver*)this);
370 PP_DEBUG(_L("ppHwDev[%x]:Initialize() decoder yet to implement MMmfVideoResourceHandler CI"), this);
373 MMmfVideoPropertiesNotifier* VPHandler = NULL;
374 VPHandler = (MMmfVideoPropertiesNotifier*)iInputDecoderDevice->CustomInterface(KUidMmfVideoPropertiesManagement);
377 PP_DEBUG(_L("ppHwDev[%x]:Initialize() Register for video property changes"), this);
378 VPHandler->MmvpnSetObserver((MMmfVideoPropertiesObserver*)this);
382 PP_DEBUG(_L("ppHwDev[%x]:Initialize() decoder yet to implement MMmfVideoPropertiesNotifier CI"), this);
386 // Initialize picture counters
387 iPictureCounters.iPicturesSkipped = 0;
388 iPictureCounters.iPicturesDisplayed = 0;
389 iPictureCounters.iTotalPictures = 0;
390 iOverflowPictureCounter = 0;
392 iPPState = EInitialized;
393 if(iPostInitializeResponse)
396 TRAP(err, iPostInitializeResponse->MmpirPostInitializeResponseL());
401 TRAP(err, iSessionManager->CreateNotifierL(iInfo().iBuffers));
405 iPPState = EInitializing;
410 iProxy->MdvppInitializeComplete(this, err);
412 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize --"), this);
415 void CNGAPostProcHwDevice::WritePictureL(TVideoPicture* aPicture)
417 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePicture bufId = %d"), this,GetID(aPicture));
419 if (iPPState==EInitializing || iPPState==EStopped || iIsInputEnded)
421 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: Unexpected state"), this);
422 User::Leave(KErrNotReady);
427 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: Invalid argument"), this);
428 User::Leave(KErrArgument);
431 iPictureCounters.iTotalPictures++;
432 if((iPPState != EPlaying) && (iFirstPictureUpdated))
434 //If decoder is fast enough, it can happen between Initialize->Start time gap between
435 //DecodeHwDevice and PostProc_HwDevice. OR between Pause->Resume time gap as well.
438 else if( iInputQ.Count() > 0 )
445 TTimeToPost timeToPost = EPostIt;
447 if(iFirstPictureUpdated)
449 timeToPost = (TTimeToPost)IsTimeToPost(pic, delta);
452 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL GCE not ready"), this );
453 if(timeToPost == EPostIt)
455 timeToPost = EDelayIt;
458 if (delta > 0x7FFFFFFF)
460 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL Too large delta .. skipping"), this );
461 timeToPost = ESkipIt;
466 if(!iSurfaceCreatedEventPublished)
468 PublishSurfaceCreated();
470 iFirstPictureUpdated = ETrue;
482 iPostingTimer->Cancel();
489 if(iIsColorConversionNeeded)
491 TVideoPicture* ccPic;
492 ccPic = DoColorConvert(pic); // output will be in ccPic
496 #ifdef _DUMP_YUV_FRAMES
499 TInt err = iSessionManager->PostPicture(iSurfaceId, GetID(pic), ETrue);
502 iProcessQ.Append(pic);
503 iCurrentPlaybackPosition = pic->iTimestamp;
519 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePicture --"), this);
524 CNGAPostProcHwDevice::PostProcessorInfoLC()
526 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PostProcessorInfoLC() ++"), this);
527 TUncompressedVideoFormat yuvFormat;
528 RArray<TUint32> SupportedPostProcess;
529 TBool SupportedHwAcceleration = ETrue; //Non-Accelerated ETrue,
530 TYuvToRgbCapabilities SupportedYuvToRgbCapab;
531 TInt32 SupportedRotations = ERotateNone; // no rotation supported
533 TBool SupportedArbitraryScaling = EFalse; // no scaling supported
534 RArray<TScaleFactor> SupportedScaleFactors;
535 TBool SupportedAntiAliasing = EFalse;
538 yuvFormat.iDataFormat = EYuvRawData;
539 yuvFormat.iYuvFormat.iYuv2RgbMatrix = 0;
540 yuvFormat.iYuvFormat.iRgb2YuvMatrix = 0;
541 yuvFormat.iYuvFormat.iAspectRatioNum = 1;
542 yuvFormat.iYuvFormat.iAspectRatioDenom = 1;
543 yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range1;
544 yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1;
545 yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedBE;
547 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
549 yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2;
550 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
552 yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range0;
553 yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1;
554 yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedBE;
555 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
557 yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2;
558 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
560 yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range0;
561 yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1;
562 yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedLE;
563 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
565 yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2;
566 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
568 yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range1;
569 yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1;
570 yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedLE;
571 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
573 yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2;
574 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
576 yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range0;
577 yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1;
578 yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedBE;
579 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
581 yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2;
582 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
584 yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range1;
585 yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1;
586 yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedBE;
587 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
589 yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2;
590 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
592 yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range0;
593 yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1;
594 yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedLE;
595 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
597 yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2;
598 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
600 yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range1;
601 yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1;
602 yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedLE;
603 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
605 yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2;
606 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
609 yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range1;
610 yuvFormat.iYuvFormat.iPattern = EYuv420Chroma1;
611 yuvFormat.iYuvFormat.iDataLayout = EYuvDataPlanar;
612 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
614 yuvFormat.iYuvFormat.iPattern = EYuv420Chroma2;
615 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
617 yuvFormat.iYuvFormat.iPattern = EYuv420Chroma3;
618 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
620 yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range0;
621 yuvFormat.iYuvFormat.iPattern = EYuv420Chroma1;
622 yuvFormat.iYuvFormat.iDataLayout = EYuvDataPlanar;
623 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
625 yuvFormat.iYuvFormat.iPattern = EYuv420Chroma2;
626 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
628 yuvFormat.iYuvFormat.iPattern = EYuv420Chroma3;
629 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
631 yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range1;
632 yuvFormat.iYuvFormat.iPattern = EYuv420Chroma1;
633 yuvFormat.iYuvFormat.iDataLayout = EYuvDataPlanar;
634 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
636 yuvFormat.iYuvFormat.iPattern = EYuv420Chroma2;
637 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
639 yuvFormat.iYuvFormat.iPattern = EYuv420Chroma3;
640 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
642 yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range0;
643 yuvFormat.iYuvFormat.iPattern = EYuv420Chroma1;
644 yuvFormat.iYuvFormat.iDataLayout = EYuvDataPlanar;
645 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
647 yuvFormat.iYuvFormat.iPattern = EYuv420Chroma2;
648 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
650 yuvFormat.iYuvFormat.iPattern = EYuv420Chroma3;
651 User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat));
653 CPostProcessorInfo* postProcessorInfo = CPostProcessorInfo::NewL(
654 KUidVideoPostProcHwDevice,
658 iSupportedInputFormats.Array(),
659 SupportedPostProcess.Array(),
660 SupportedHwAcceleration,
661 ETrue, //Direct Display
662 SupportedYuvToRgbCapab,
664 SupportedArbitraryScaling,
665 SupportedScaleFactors.Array(),
666 SupportedAntiAliasing);
668 CleanupStack::PushL(postProcessorInfo);
669 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PostProcessorInfoLC() --"), this);
670 return postProcessorInfo;
673 void CNGAPostProcHwDevice::MmvprcGetPlayRateCapabilitiesL(TVideoPlayRateCapabilities& aCap)
675 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcGetPlayRateCapabilitiesL ++"), this);
676 aCap.iPlayForward = ETrue;
677 aCap.iPlayBackward = ETrue;
678 aCap.iStepForward = ETrue;
679 aCap.iStepBackward = ETrue;
680 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcGetPlayRateCapabilitiesL --"), this);
683 void CNGAPostProcHwDevice::MmvprcSetPlayRateL(const TInt aRate)
685 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcSetPlayRateL ++"), this);
689 iKeyFrameMode = ETrue;
693 iKeyFrameMode = EFalse;
694 ResetCountingBuffer();
696 //In fast forward go direct to key frame mode if speed >4X =
697 if (iPlayRate>KDefPlayRate*4)
701 iFPObserver->MmvproKeyFrameModeRequest();
705 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcSetPlayRateL=%d --"), this, aRate);
708 TInt CNGAPostProcHwDevice::MmvprcPlayRateL()
710 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcPlayRateL= ++"), this);
711 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcPlayRateL= --"), this);
715 void CNGAPostProcHwDevice::MmvprcStepFrameL(const TInt aStep)
717 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcStepFrameL= ++"), this);
718 iStepFrameCount = aStep;
719 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcStepFrameL=%d --"), this, aStep);
722 void CNGAPostProcHwDevice::MmvprcSetObserver(MMmfVideoPlayRateObserver& aObserver)
724 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcSetObserver ++"), this);
725 iFPObserver = &aObserver;
726 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcSetObserver --"), this);
729 void CNGAPostProcHwDevice::MmvsoSetSecureOutputL(TBool aSecure)
731 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvsoSetSecureOutputL aSecure = %d++"), this, aSecure);
735 iSurfaceMask = surfaceHints::EAllowInternalOnly;
739 iSurfaceMask = surfaceHints::EAllowAllExternals;
741 if(!iSurfaceId.IsNull())
746 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvsoSetSecureOutputL -- leaving err = %d"), this, err);
750 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvsoSetSecureOutputL --"), this);
753 void CNGAPostProcHwDevice::MmavsoSetAllowedOutputL(TUint aAllowedOutputMask)
755 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmavsoSetAllowedOutputL aAllowedOutputMask=0x%08x ++"), this,aAllowedOutputMask);
757 iSurfaceMask = surfaceHints::EAllowInternalOnly;
758 if (aAllowedOutputMask == EVideoAllowAll)
760 iSurfaceMask = surfaceHints::EAllowAllExternals;
762 else if (aAllowedOutputMask == EVideoAllowInternalOnly)
764 iSurfaceMask = surfaceHints::EAllowInternalOnly;
768 // we hope to find some valid output prefs
769 if (aAllowedOutputMask & EVideoAllowAnalog)
771 iSurfaceMask |= surfaceHints::EAllowAnalog;
773 if (aAllowedOutputMask & EVideoAllowMacroVision)
775 iSurfaceMask |= surfaceHints::EAllowAnalogProtectionRequired;
777 if (aAllowedOutputMask & EVideoAllowHDMI)
779 iSurfaceMask |= surfaceHints::EAllowDigital;
781 if (aAllowedOutputMask & EVideoAllowHdmiHdcpRequested)
783 iSurfaceMask |= surfaceHints::EAllowDigitalProtectionRequested;
785 if (aAllowedOutputMask & EVideoAllowHdmiHdcpRequired)
787 iSurfaceMask |= surfaceHints::EAllowDigitalProtectionRequired;
791 if((!iSurfaceId.IsNull()))
796 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmavsoSetAllowedOutputL -- leaving err = %d"), this, err);
800 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmavsoSetAllowedOutputL --"), this);
803 void CNGAPostProcHwDevice::SetPostProcessTypesL(TUint32 /*aCombination*/)
805 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPostProcessTypesL ++"), this);
807 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPostProcessTypesL --"), this);
810 void CNGAPostProcHwDevice::SetInputCropOptionsL(const TRect& /*aRect*/)
812 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputCropOptionsL ++"), this);
814 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputCropOptionsL --"), this);
817 void CNGAPostProcHwDevice::SetYuvToRgbOptionsL( const TYuvToRgbOptions& /*aOptions*/, const TYuvFormat& /*aYuvFormat*/, TRgbFormat /*aRgbFormat*/)
819 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetYuvToRgbOptionsL ++"), this);
821 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetYuvToRgbOptionsL --"), this);
824 void CNGAPostProcHwDevice::SetYuvToRgbOptionsL(const TYuvToRgbOptions& /*aOptions*/)
826 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetYuvToRgbOptionsL ++"), this);
828 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetYuvToRgbOptionsL --"), this);
831 void CNGAPostProcHwDevice::SetRotateOptionsL(TRotationType )
833 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetRotateOptionsL ++"), this);
835 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetRotateOptionsL --"));
838 void CNGAPostProcHwDevice::SetScaleOptionsL(const TSize& /*aTargetSize*/, TBool /*aAntiAliasFiltering*/)
840 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetScaleOptionsL ++"), this);
842 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetScaleOptionsL --"), this);
845 void CNGAPostProcHwDevice::SetOutputCropOptionsL(const TRect& /*aRect*/)
847 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetOutputCropOptionsL ++"), this);
849 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetOutputCropOptionsL --"), this);
852 void CNGAPostProcHwDevice::SetPostProcSpecificOptionsL(const TDesC8& )
857 void CNGAPostProcHwDevice::CommitL()
859 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CommitL ++"), this);
861 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CommitL --"), this);
864 void CNGAPostProcHwDevice::Revert()
866 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Revert ++"), this);
868 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Revert --"), this);
871 void CNGAPostProcHwDevice::StartDirectScreenAccessL( const TRect& /*aVideoRect*/, CFbsScreenDevice& /*aScreenDevice*/, const TRegion& /*aClipRegion*/)
873 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:StartDSA ++"), this);
875 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:StartDSA --"), this);
878 void CNGAPostProcHwDevice::AbortDirectScreenAccess()
880 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AbortDSA ++"), this);
882 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AbortDSA --"), this);
885 void CNGAPostProcHwDevice::SetScreenClipRegion(const TRegion& /*aRegion*/)
887 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetScreenClipRegion ++"), this);
890 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetScreenClipRegion --"), this);
893 void CNGAPostProcHwDevice::SetPauseOnClipFail(TBool )
895 //ignore. Post Processor will always behave as aPause==False.
898 TBool CNGAPostProcHwDevice::IsPlaying()
900 if( iPPState == EPlaying)
910 void CNGAPostProcHwDevice::Redraw()
912 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw ++"), this);
914 if(iRedrawSurfaceInUse && !iRedrawDone)
919 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw -- failed to AddHints %d"),
921 iProxy->MdvppFatalError(this, err);
924 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw registering the temp surface"), this);
925 err = RegisterSurface(iSurfaceId);
928 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw -- failed to Register Surface %d"),
930 iSurfaceHandler->DestroySurface(iSurfaceId);
931 iSurfaceId = TSurfaceId::CreateNullId();
932 iProxy->MdvppFatalError(this, err);
935 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw registering the temp surface done"), this);
936 err = iSessionManager->PostPicture(iSurfaceId, 0, EFalse);
939 iProxy->MdvppFatalError(this, err);
942 PublishSurfaceCreated();
945 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw --"), this);
948 void CNGAPostProcHwDevice::Start()
950 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Start ++"), this);
953 //TBC: when buffers given to post proc even before start.
954 //Even the buffers must be available to PostProc but not displayed.
955 //This will happen only when neighbouring decodeHwDevice decodes earlier than Start()
956 //call. Need to check if MDF guidelines allow this.
958 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Start --"), this);
961 void CNGAPostProcHwDevice::Stop()
963 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Stop ++"), this);
967 iSessionManager->CancelNotifiers();
971 iPostingTimer->Cancel();
976 //Stop must keep on displaying the last frame. Blank Screen must not be visible
977 //to client. No Unregistering of surface should happen here.
978 //This Req is not necessary anymore. Only applicable to Pause.
980 RDebug::Printf("------ Statistics of Post Processor ------");
981 RDebug::Printf(" Pictures Received : %d", iPictureCounters.iTotalPictures);
982 RDebug::Printf(" Pictures Displayed: %d", iPictureCounters.iPicturesDisplayed);
983 RDebug::Printf(" Pictures Skipped : %d", iPictureCounters.iPicturesSkipped);
984 RDebug::Printf("------------------------------------------");
986 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Stop --"), this);
989 void CNGAPostProcHwDevice::Pause()
991 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Pause ++"), this);
993 iPostingTimer->Cancel();
994 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Pause --"), this);
997 void CNGAPostProcHwDevice::Resume()
999 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Resume ++"), this);
1000 iPPState = EPlaying;
1002 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Resume --"), this);
1005 void CNGAPostProcHwDevice::SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition)
1007 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPosition ++"), this);
1009 if (iPPState == EInitializing)
1011 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPosition FAILED: Unexpected state"), this);
1014 if (iPPState == EPaused)
1016 iFirstPictureUpdated = EFalse;
1018 iCurrentPlaybackPosition = aPlaybackPosition;
1022 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPosition --"), this);
1025 void CNGAPostProcHwDevice::FreezePicture(const TTimeIntervalMicroSeconds& )
1030 void CNGAPostProcHwDevice::ReleaseFreeze(const TTimeIntervalMicroSeconds& )
1035 TTimeIntervalMicroSeconds
1036 CNGAPostProcHwDevice::PlaybackPosition()
1038 if (iPPState == EInitializing)
1040 return TTimeIntervalMicroSeconds(0);
1043 return iCurrentPlaybackPosition;
1046 TUint CNGAPostProcHwDevice::PictureBufferBytes()
1051 void CNGAPostProcHwDevice::GetPictureCounters( CMMFDevVideoPlay::TPictureCounters& aCounters)
1053 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetPictureCounters ++"), this);
1055 if (iPPState == EInitializing)
1057 aCounters = iPictureCounters;
1059 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetPictureCounters --"), this);
1062 void CNGAPostProcHwDevice::SetComplexityLevel(TUint )
1067 TUint CNGAPostProcHwDevice::NumComplexityLevels()
1073 void CNGAPostProcHwDevice::GetComplexityLevelInfo(TUint , CMMFDevVideoPlay::TComplexityLevelInfo& )
1078 void CNGAPostProcHwDevice::ReturnPicture(TVideoPicture* )
1080 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReturnPicture +-"), this);
1081 //not required for direct rendering
1084 TBool CNGAPostProcHwDevice::GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& /*aFormat*/)
1086 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL %d %d ++"), this, iVBMEnabled, iProcessQ.Count());
1087 TVideoPicture* pic = NULL;
1088 TInt err = KErrNone;
1089 TBool frameAvailable =EFalse;
1090 tWndParam inputCropWindow;
1091 tWndParam outputCropWindow;
1092 tBaseVideoFrame inputFrame;
1093 inputFrame.lum = NULL;
1095 if(aPictureData.iDataFormat == ERgbFbsBitmap)
1097 if(iProcessQ.Count())
1099 pic = iProcessQ[0]; //frame already submitted for display
1101 else if(iInputQ.Count())
1103 pic = iInputQ[0]; //frame yet to be displayed
1109 inputFrame.lum = (TUint8*)pic->iData.iRawData->Ptr();
1113 if (iInputDecoderDevice)
1115 MMmfVideoFetchFrame* VFHandler = NULL;
1116 VFHandler = (MMmfVideoFetchFrame*)iInputDecoderDevice->CustomInterface(KUidMMFVideoFetchFrame);
1119 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL() fetch frame"), this);
1120 inputFrame.lum = (TUint8*)VFHandler->MmvffGetFrame(GetID(pic));
1124 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL() decoder yet to implement MMmfVideoFetchFrame CI"), this);
1131 inputFrame.cb = inputFrame.lum + iPicSize.iWidth * iPicSize.iHeight;
1133 if( ((iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma1) ||
1134 (iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma2) ||
1135 (iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma3) ))
1137 inputFrame.cr = inputFrame.lum + (iPicSize.iWidth * iPicSize.iHeight*5)/4;
1141 inputFrame.cr = inputFrame.lum + (iPicSize.iWidth * iPicSize.iHeight*3)/2;
1144 inputFrame.width = (unsigned short)iPicSize.iWidth;
1145 inputFrame.height = (unsigned short)iPicSize.iHeight;
1147 outputCropWindow.wndHeight = iPicSize.iHeight;
1148 outputCropWindow.wndWidth = iPicSize.iWidth;
1149 outputCropWindow.xOffset = 0;
1150 outputCropWindow.yOffset = 0;
1152 inputCropWindow.wndHeight = iPicSize.iHeight;
1153 inputCropWindow.wndWidth = iPicSize.iWidth;
1154 inputCropWindow.xOffset = 0;
1155 inputCropWindow.yOffset = 0;
1158 User::LeaveIfError(fbs.Connect());
1159 CFbsBitmap* iOutBitmap = aPictureData.iRgbBitmap;
1160 TInt status = iOutBitmap->Resize(iPicSize);
1161 if (status == KErrNone)
1163 // Lock the heap to prevent the FBS server from invalidating the address
1164 iOutBitmap->LockHeap();
1165 TUint8* dataAddress = (TUint8*)iOutBitmap->DataAddress();
1166 err = ColorConvert(&inputFrame, dataAddress, &inputCropWindow, &outputCropWindow);
1167 iOutBitmap->UnlockHeap();
1168 frameAvailable = ETrue;
1175 err = KErrNotSupported;
1181 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL --"), this);
1182 return(frameAvailable);
1185 void CNGAPostProcHwDevice::InputEnd()
1187 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:InputEnd ++"), this);
1189 if (iPPState!=EPlaying && iPPState!=EPaused)
1191 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:InputEnd FAILED: Unexpected state"), this);
1194 iIsInputEnded = ETrue;
1196 if( (iProcessQ.Count() <= 1) && (iInputQ.Count() == 0))
1198 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:InputEnd() Stream end"), this);
1199 iProxy->MdvppStreamEnd();
1202 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:InputEnd --"), this);
1205 TAny* CNGAPostProcHwDevice::CustomInterface(TUid aInterface)
1207 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CustomInterface UID = %d ++"), this, aInterface.iUid);
1209 if (aInterface == KUidMmfVideoBufferManagement)
1211 return (MMmfVideoBufferManagement *)this;
1213 if (aInterface == KUidMMFVideoSurfaceSupport)
1215 return (MMMFVideoSurfaceSupport *)this;
1217 if (aInterface == KUidMMFVideoSurfaceHandleControl)
1219 return (MMmfVideoSurfaceHandleControl *)this;
1221 if (aInterface == KUidMmfVideoPlayRateControl)
1223 return (MMmfVideoPlayRateControl *)this;
1225 if (aInterface == KMmfVideoAdvancedSecureOutputUid)
1227 return (MMmfAdvancedVideoSecureOutput *)this;
1229 if (aInterface == KUidMmfVideoResourceManagement)
1231 return (MMmfVideoResourceObserver *)this;
1233 if (aInterface == KUidMmfPostInitializeRequest)
1235 return (MMmfPostInitializeRequest *)this;
1237 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CustomInterface --"), this);
1241 void CNGAPostProcHwDevice::BufferAvailable(TInt aBufId, TInt aStatus)
1243 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CNGAPostProcHwDevice::BufferAvailable aStatus = %d aBufId = %d++"), this, aStatus, aBufId);
1244 TVideoPicture* pic = NULL;
1245 if((aStatus != KErrNone) && (aStatus != KErrOverflow) && (aStatus != KErrNotVisible))
1247 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:BufferAvailable FAILED: aStatus = %d"), this, aStatus);
1248 iProxy->MdvppFatalError(this, aStatus);
1251 if(aStatus == KErrOverflow)
1253 iOverflowPictureCounter++;
1259 for(TInt i=0; i < iProcessQ.Count(); i++)
1261 if(iVBMBufferReferenceQ[aBufId] == iProcessQ[i])
1264 iProcessQ.Remove(i);
1265 ReturnPicToDecoder(pic);
1266 if (iIsColorConversionNeeded)
1268 AddPictureToColorConversionQ(pic);
1272 AddPictureToVBMQ(pic);
1280 for(TInt i=0; i < iProcessQ.Count(); i++)
1283 if (iUsingExternalSurface)
1285 bufId = GetExternalBufferID(iProcessQ[i]);
1289 bufId = GetID(iProcessQ[i]);
1292 if (aBufId == bufId)
1295 iProcessQ.Remove(i);
1296 ReturnPicToDecoder(pic);
1302 if(aStatus == KErrNone)
1304 if (!iKeyFrameMode && iPlayRate>KDefPlayRate)
1306 if (iSkippedFramesCountingBuffer[iCurrentPosInFramesCountingBuffer]==1)
1308 iSkippedFramesCountingBuffer[iCurrentPosInFramesCountingBuffer] = 0;
1309 iSkippedFramesInLast64Frames--;
1311 iCurrentPosInFramesCountingBuffer = ++iCurrentPosInFramesCountingBuffer%64;
1313 iPictureCounters.iPicturesDisplayed++;
1314 if (iStepFrameCount != 0)
1316 iStepFrameCount > 0 ? iStepFrameCount-- : iStepFrameCount++;
1317 if (iStepFrameCount==0 && iFPObserver)
1319 iFPObserver->MmvproStepFrameComplete(pic->iTimestamp);
1324 if(iPPState == EPlaying)
1329 if( iIsInputEnded && (iProcessQ.Count() <= 1) && (iInputQ.Count() == 0))
1331 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:BufferAvailable() Stream end"), this);
1332 iProxy->MdvppStreamEnd();
1335 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CNGAPostProcHwDevice::BufferAvailable --"), this);
1338 //=== MMmfVideoBufferManagement ===
1339 void CNGAPostProcHwDevice::MmvbmSetObserver(MMmfVideoBufferManagementObserver* aObserver)
1341 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetObserver() ++"), this);
1343 if (iPPState != EInitializing)
1345 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetObserver FAILED: Unexpected state"), this);
1346 iProxy->MdvppFatalError(this, KErrNotReady);
1349 iVBMObserver = aObserver;
1351 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetObserver() --"), this);
1355 void CNGAPostProcHwDevice::MmvbmEnable(TBool aEnable)
1357 if (iPPState != EInitializing)
1359 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmEnable FAILED: Unexpected state"), this);
1360 iProxy->MdvppFatalError(this, KErrNotReady);
1363 iVBMEnabled = aEnable;
1366 void CNGAPostProcHwDevice::MmvbmSetBufferOptionsL(const TBufferOptions& aOptions)
1368 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetBufferOptionsL ++"), this);
1370 if (iPPState != EInitializing)
1372 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetBufferOptionsL FAILED: Unexpected state"), this);
1373 User::Leave(KErrNotReady);
1376 // why limiting the number of buffers? any particular reason for this?
1377 //if (aOptions.iNumInputBuffers > KMaxVBMBuffers || aOptions.iNumInputBuffers <= 1) //at least two buffers
1378 if (aOptions.iNumInputBuffers <= 1) //at least two buffers
1380 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetBufferOptionsL FAILED: Input buffer count limit"), this);
1381 User::Leave(KErrNotSupported);
1384 if (aOptions.iNumInputBuffers == 0
1385 || aOptions.iBufferSize.iWidth <= KMinVBMInputWidth
1386 || aOptions.iBufferSize.iHeight <= KMinVBMInputHeight
1387 || aOptions.iBufferSize.iWidth > KMaxVBMInputWidth
1388 || aOptions.iBufferSize.iHeight > KMaxVBMInputHeight)
1390 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetBufferOptionsL FAILED: Unexpected buffer size"), this);
1391 User::Leave(KErrArgument);
1394 iVBMBufferOptions.iNumInputBuffers = aOptions.iNumInputBuffers;
1395 iVBMBufferOptions.iBufferSize = aOptions.iBufferSize;
1397 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetBufferOptionsL --"), this);
1400 void CNGAPostProcHwDevice::MmvbmGetBufferOptions(TBufferOptions& aOptions)
1402 if (iPPState == EInitializing)
1404 aOptions = iVBMBufferOptions;
1408 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferOptions FAILED: Unexpected state"), this);
1409 iProxy->MdvppFatalError(this, KErrNotReady);
1413 TVideoPicture* CNGAPostProcHwDevice::MmvbmGetBufferL(const TSize& aSize)
1415 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() ++"), this);
1417 TInt err = KErrNone;
1418 TVideoPicture* lPic = NULL;
1420 if (iPPState == EInitializing)
1422 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() FAILED: Unexpected state"), this);
1423 User::Leave(KErrNotReady);
1426 if (aSize.iWidth < KMinVBMInputWidth
1427 || aSize.iHeight < KMinVBMInputHeight
1428 || aSize.iWidth > iVBMBufferOptions.iBufferSize.iWidth
1429 || aSize.iHeight > iVBMBufferOptions.iBufferSize.iHeight)
1431 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() FAILED: Unexpected buffer size w=%d h=%d "), this,aSize.iWidth,aSize.iHeight );
1432 User::Leave(KErrNotSupported);
1435 if(iVBMBufferReferenceQ.Count() == 0)
1438 err = SetupSurface();
1441 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() Surface Setup Failed %d"), this, err);
1446 if(!iVBMBufferQ.Count())
1448 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() WARNING: Queue buffer count zero"), this);
1452 lPic = iVBMBufferQ[0];
1453 iVBMBufferQ.Remove(0);
1455 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() -- %d"), this, lPic);
1459 void CNGAPostProcHwDevice::MmvbmReleaseBuffer(TVideoPicture* aBuffer)
1461 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmReleaseBuffer() ++"), this);
1465 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmReleaseBuffer() FAILED: Invalid buffer ptr"), this);
1466 iProxy->MdvppFatalError(this, KErrArgument);
1469 TInt err = iVBMBufferQ.Append(aBuffer);
1472 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmReleaseBuffer() FAILED: Failed to append"), this);
1473 iProxy->MdvppFatalError(this, err);
1476 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmReleaseBuffer() --"), this);
1479 //=== MMMFVideoSurfaceSupport ===
1481 void CNGAPostProcHwDevice::MmvssUseSurfaces()
1483 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssUseSurfaces() ++"), this);
1485 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssUseSurfaces() --"), this);
1488 TInt CNGAPostProcHwDevice::MmvshcCreateSurface(const RSurfaceManager::TSurfaceCreationAttributes& aAttributes, TInt aHandle, TSurfaceId& aSurfaceId)
1490 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcCreateSurface() ++"), this);
1493 if(!iSurfaceId.IsNull())
1495 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssCreateSurface Cleaning Surface"), this);
1497 if (iVideoSurfaceObserver && iSurfaceCreatedEventPublished)
1499 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcCreateSurface - Telling client to remove old surface"), this);
1500 iVideoSurfaceObserver->MmvsoRemoveSurface();
1501 iSurfaceCreatedEventPublished = EFalse;
1505 // We never told the client about the surface, so we must destroy it ourselves
1506 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface - Destroying old surface"), this);
1507 TInt numScreens = iWsSession.NumberOfScreens();
1508 for(TInt i=0;i < numScreens;i++)
1510 iWsSession.UnregisterSurface(i, iSurfaceId);
1513 iSurfaceHandler->DestroySurface(iSurfaceId);
1515 //remove any handle to chunk. not needed perhaps
1520 // Create the surface handler if it doesn't exist.
1521 if (!iSurfaceHandler)
1523 TRAP(err, iSurfaceHandler = CNGAPostProcSurfaceHandler::NewL());
1524 if (err != KErrNone)
1526 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssCreateSurface -- failed to create SurfaceHandler."), this);
1531 iChunk.SetHandle(aHandle);
1532 err = iSurfaceHandler->CreateSurface(aAttributes, aSurfaceId, iChunk);
1533 if (err != KErrNone)
1535 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssCreateSurface -- failed to create surface %d"), this, err);
1538 iSurfaceId = aSurfaceId;
1539 iIsExternalChunk = ETrue;
1541 err = RegisterSurface(iSurfaceId);
1542 if (err != KErrNone)
1544 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssCreateSurface -- failed RegisterSurface %d"), this, err);
1545 iSurfaceHandler->DestroySurface(iSurfaceId);
1546 iSurfaceId = TSurfaceId::CreateNullId();
1550 err = iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo);
1551 if (err != KErrNone)
1553 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssCreateSurface -- failed to get Surface info %d"), this, err);
1557 if(iAttributes().iPixelFormat == EUidPixelFormatYUV_422Interleaved)
1559 iVideoFrameBufSize = iInfo().iSize.iWidth * iInfo().iSize.iHeight * 2;
1562 {//EStUidPixelFormatYUV_420MB
1563 // EUidPixelFormatYUV_420Planar
1564 iVideoFrameBufSize = iInfo().iSize.iWidth * iInfo().iSize.iHeight * 3/2;
1568 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcCreateSurface err=%d"), this, err);
1572 void CNGAPostProcHwDevice::MmvssSetObserver(MMMFVideoSurfaceObserver& aObserver)
1574 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSetObserver() ++"), this);
1575 iVideoSurfaceObserver = &aObserver;
1576 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSetObserver() --"), this);
1579 void CNGAPostProcHwDevice::MmvssGetSurfaceParametersL(TSurfaceId& aSurfaceId,
1580 TRect& aCropRect, TVideoAspectRatio& aPixelAspectRatio)
1582 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() ++"), this);
1584 iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo);
1585 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() \
1586 surfaceWidth = %d surfaceHeight = %d SurfaceId = 0x%x --"),
1587 this, iInfo().iSize.iWidth, iInfo().iSize.iHeight, iSurfaceId);
1588 aSurfaceId = iSurfaceId;
1589 aCropRect = TRect(0, 0, iInfo().iSize.iWidth, iInfo().iSize.iHeight);
1590 if((iPicSize.iWidth > 0) && (iPicSize.iHeight > 0))
1592 aCropRect.Intersection( iPicSize);
1594 aPixelAspectRatio = TVideoAspectRatio(iAspectRatioNum,iAspectRatioDenom);
1595 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() \
1596 cropRectWidth = %d cropRectHeight = %d"), this, aCropRect.Width(), aCropRect.Height());
1597 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() \
1598 PAR Num = %d PAR Denom = %d"), this, aPixelAspectRatio.iNumerator, aPixelAspectRatio.iDenominator);
1599 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() --"), this);
1602 void CNGAPostProcHwDevice::MmvssSurfaceRemovedL(const TSurfaceId& aSurfaceId)
1604 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL()++"), this);
1605 if(!aSurfaceId.IsNull())
1607 if(iSurfaceId == aSurfaceId)
1608 {//closing down top surface....current surface.
1611 iSessionManager->CancelNotifiers();
1614 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL(): UnregisterSurface ID = 0x%x"), this, aSurfaceId );
1615 TInt numScreens = iWsSession.NumberOfScreens();
1616 for(TInt i=0;i < numScreens;i++)
1618 iWsSession.UnregisterSurface(i, aSurfaceId);
1621 iSurfaceHandler->DestroySurface(aSurfaceId);
1622 if(iSurfaceId == aSurfaceId)
1624 iSurfaceCreatedEventPublished = EFalse;
1625 iSurfaceId = TSurfaceId::CreateNullId();
1626 if(!iIsExternalChunk)
1633 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL() --"), this);
1636 // === MMmfVideoPropertiesObserver ===
1638 void CNGAPostProcHwDevice::MmvpoUpdateVideoProperties(const TYuvFormat& aYuvFormat, const TSize& aPictureSize)
1640 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties ++"), this);
1641 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties PAR \
1642 iAspectRatioNum = %d, iAspectRatioDenom = %d"), this,
1643 aYuvFormat.iAspectRatioNum,aYuvFormat.iAspectRatioDenom);
1644 iPicSize = aPictureSize;
1645 iAspectRatioNum = aYuvFormat.iAspectRatioNum;
1646 iAspectRatioDenom = aYuvFormat.iAspectRatioDenom;
1647 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties Picture Size \
1648 iWidth = %d, iHeight = %d, iSurfaceCreatedEventPublished = %d"),
1649 this, iPicSize.iWidth,iPicSize.iHeight, iSurfaceCreatedEventPublished?1:0);
1653 iVPObserver->MmvpoUpdateVideoProperties(aYuvFormat, aPictureSize);
1655 if(iVideoSurfaceObserver && iSurfaceCreatedEventPublished)
1657 iVideoSurfaceObserver->MmvsoSurfaceParametersChanged();
1659 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties --"), this);
1662 // === MMmfVideoResourceObserver ===
1664 void CNGAPostProcHwDevice::MmvroResourcesLost(TUid )
1666 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost ++"), this);
1669 iResourceLost = ETrue;
1670 iRedrawDone = EFalse;
1673 iSessionManager->CancelNotifiers();
1675 if(iVideoSurfaceObserver && iSurfaceCreatedEventPublished)
1677 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost - Telling client to remove surface"), this);
1678 iVideoSurfaceObserver->MmvsoRemoveSurface();
1679 iSurfaceCreatedEventPublished = EFalse;
1682 else if(iResourceLost && iRedrawDone)
1684 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost ResourceLost happening \
1685 while Postprocessor is already in ResourceLoss state"),
1687 iProxy->MdvppFatalError(this, KErrHardwareNotAvailable);
1692 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost Ignoring the \
1693 duplicate ResourceLoss call"),
1696 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost --"), this);
1699 // === MMmfVideoPropertiesNotifier ===
1701 void CNGAPostProcHwDevice::MmvpnSetObserver(MMmfVideoPropertiesObserver* aObserver)
1703 PP_DEBUG(_L("ppHwDev[%x]::MmvpnSetObserver ++"), this);
1704 iVPObserver = aObserver;
1705 PP_DEBUG(_L("ppHwDev[%x]::MmvpnSetObserver --"), this);
1708 void CNGAPostProcHwDevice::MmvroResourcesRestored(TUid )
1710 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvroResourcesRestored ++"), this);
1711 iFirstPictureUpdated = EFalse;
1712 iResourceLost = EFalse;
1713 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvroResourcesRestored state=%d --"),
1717 void CNGAPostProcHwDevice::MmvshcSetSurfaceHandle(const TSurfaceId &aSurfaceID)
1720 SetupExternalSurface(aSurfaceID);
1724 void CNGAPostProcHwDevice::MmvshcRedrawBufferToSurface(TPtrC8& aRedrawBuffer)
1726 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface ++"), this);
1731 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface -- Creating %d x %d surface"), this, iPicSize.iWidth, iPicSize.iHeight);
1733 TInt err = KErrNone;
1734 SetSurfaceAttributes(iPicSize, 1);
1736 err = iSurfaceHandler->CreateSurface(iAttributes, iSurfaceId);
1737 if (err != KErrNone)
1739 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to create Surface %d"),
1741 iProxy->MdvppFatalError(this, err);
1745 err = iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo);
1746 if (err != KErrNone)
1748 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to get Surface info %d"),
1750 iSurfaceHandler->DestroySurface(iSurfaceId);
1751 iSurfaceId = TSurfaceId::CreateNullId();
1752 iProxy->MdvppFatalError(this, err);
1756 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface() \
1757 surfaceWidth = %d surfaceHeight = %d surfaceStride = %d"), this, iInfo().iSize.iWidth, iInfo().iSize.iHeight, iInfo().iStride);
1759 TInt redrawBufferSize = aRedrawBuffer.Size();
1760 TInt surfaceSize = iInfo().iStride * iInfo().iSize.iHeight;
1762 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface RedrawBuffer size= %d Surface size = %d"), this, redrawBufferSize, surfaceSize);
1764 // Check whether redraw buffer will fit onto the surface.
1765 // If this check fails then we won't raise a fatal error - We just won't create the redraw surface
1766 if (redrawBufferSize > surfaceSize)
1768 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface Redraw buffer size larger than surface size"), this);
1769 iSurfaceHandler->DestroySurface(iSurfaceId);
1770 iSurfaceId = TSurfaceId::CreateNullId();
1774 err = iSurfaceHandler->MapSurface(iSurfaceId, iChunk);
1775 if (err != KErrNone)
1777 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to map Surface %d"),
1779 iSurfaceHandler->DestroySurface(iSurfaceId);
1780 iSurfaceId = TSurfaceId::CreateNullId();
1781 iProxy->MdvppFatalError(this, err);
1784 iIsExternalChunk = EFalse;
1785 if((err = iSurfaceHandler->GetBufferOffset(iSurfaceId, 0, offset)) != KErrNone)
1787 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface offset query failed %d"), this, err);
1788 iSurfaceHandler->DestroySurface(iSurfaceId);
1789 iSurfaceId = TSurfaceId::CreateNullId();
1791 iProxy->MdvppFatalError(this, err);
1795 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface offset = %d"), this, offset);
1797 lPtr = reinterpret_cast<TUint8*>(iChunk.Base() + offset);
1798 memcpy((TAny *)lPtr, (TAny *)aRedrawBuffer.Ptr(), redrawBufferSize);
1800 iRedrawSurfaceInUse = ETrue;
1802 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface(): New surface = 0x%x"), this, iSurfaceId);
1804 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface error = %d --"), this, err);
1807 TInt CNGAPostProcHwDevice::SetupExternalSurface(const TSurfaceId &aSurfaceID)
1809 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface(): aSurfaceID = 0x%x"), this, aSurfaceID );
1811 TInt err = KErrNone;
1813 if(!iSurfaceId.IsNull())
1815 if (iVideoSurfaceObserver && iSurfaceCreatedEventPublished)
1817 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface - Telling client to remove old surface"), this);
1818 iVideoSurfaceObserver->MmvsoRemoveSurface();
1819 iSurfaceCreatedEventPublished = EFalse;
1823 // We never told the client about the surface, so we must destroy it ourselves
1824 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface - Destroying old surface"), this);
1825 TInt numScreens = iWsSession.NumberOfScreens();
1826 for(TInt i=0;i < numScreens;i++)
1828 iWsSession.UnregisterSurface(i, iSurfaceId);
1831 iSurfaceHandler->DestroySurface(iSurfaceId);
1837 iSurfaceId = aSurfaceID;
1838 iUsingExternalSurface = ETrue;
1839 iRedrawSurfaceInUse = EFalse;
1841 // Create the surface handler if it doesn't exist.
1842 if (!iSurfaceHandler)
1844 TRAP(err, iSurfaceHandler = CNGAPostProcSurfaceHandler::NewL());
1845 if (err != KErrNone)
1847 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface -- failed to create SurfaceHandler."), this);
1852 err = iSurfaceHandler->OpenSurface(iSurfaceId);
1853 if (err != KErrNone)
1855 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface -- failed OpenSurface %d"),
1860 if (err != KErrNone)
1862 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface -- failed to AddHints %d"),
1866 err = RegisterSurface(iSurfaceId);
1867 if (err != KErrNone)
1869 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface -- failed RegisterSurface %d"),
1871 iSurfaceHandler->DestroySurface(iSurfaceId);
1872 iSurfaceId = TSurfaceId::CreateNullId();
1876 err = iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo);
1877 if (err != KErrNone)
1879 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface -- failed to get Surface info %d"),
1884 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface err=%d"), this, err);
1889 TVideoPicture* CNGAPostProcHwDevice::CreateBuffersL(TInt aBufId)
1891 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateBuffersL ++"), this);
1893 TVideoPicture* lVideoPicture = NULL;
1898 lVideoPicture = new (ELeave) TVideoPicture;
1899 CleanupStack::PushL(lVideoPicture);
1900 if(TInt err = iSurfaceHandler->GetBufferOffset(iSurfaceId, aBufId, offset) != KErrNone)
1902 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateBuffersL offset query failed %d"), this, err);
1904 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateBuffersL offset = %d id =%d --"), this, offset, aBufId);
1906 lPtr = reinterpret_cast<TUint8*>(iChunk.Base() + offset);
1908 lTemp = new (ELeave) TPtr8(lPtr, 0, (iVideoFrameBufSize ));
1909 CleanupStack::PushL(lTemp);
1911 lVideoPicture->iData.iRawData = lTemp;
1912 lVideoPicture->iHeader = NULL ;
1913 lVideoPicture->iLayerBitRates = NULL ;
1915 CleanupStack::Pop(2);
1917 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateVBMBuffersL --"), this);
1918 return lVideoPicture;
1921 void CNGAPostProcHwDevice::CreateVBMBuffersL()
1923 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateVBMBuffersL ++"), this);
1925 TInt err = KErrNone;
1926 TVideoPicture* pic = NULL;
1927 iVBMBufferReferenceQ.Reset();
1928 iVBMBufferQ.Reset();
1929 iColorConversionQ.Reset();
1931 for(TInt i = 0; i < iVBMBufferOptions.iNumInputBuffers; i++)
1933 TRAP(err, pic = CreateBuffersL(i));
1934 if (err != KErrNone)
1936 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create VBM buffer %d"), this, err);
1940 // This will hold the references which will be used in destructor
1941 User::LeaveIfError(iVBMBufferReferenceQ.Append(pic));
1942 User::LeaveIfError(iVBMBufferQ.Append(pic));
1944 if(iIsColorConversionNeeded)
1946 for(TInt i = iVBMBufferOptions.iNumInputBuffers ;
1947 i < (iVBMBufferOptions.iNumInputBuffers + KColorConversionBuffers ); i++)
1949 TRAP(err, pic = CreateBuffersL(i));
1950 if (err != KErrNone)
1952 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create VBM buffer %d"), this, err);
1956 // This will hold the references which will be used in destructor
1957 User::LeaveIfError(iVBMBufferReferenceQ.Append(pic));
1958 User::LeaveIfError(iColorConversionQ.Append(pic));
1962 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateVBMBuffersL --"), this);
1965 void CNGAPostProcHwDevice::ReturnPicToDecoder(TVideoPicture* aPic)
1967 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReturnPicToDecoder ++"), this);
1970 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputPicture FAILED: Invalid pic ptr."), this);
1974 if (iInputDecoderDevice)
1976 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputPicture .. before return picture. 2"), this);
1977 iInputDecoderDevice->ReturnPicture(aPic);
1980 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReturnPicToDecoder --"), this);
1983 TInt CNGAPostProcHwDevice::AttemptToPost()
1985 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AttemptToPost ++ Q:%d"), this, iInputQ.Count());
1986 if (iPPState == EPaused)
1991 TInt err = KErrNotReady;
1992 TInt count = iInputQ.Count();
1993 TBool bDone = EFalse;
1994 TVideoPicture* pic = PeekQ();
1995 while(pic && !bDone)
1999 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AttemptToPost GCE not ready"), this );
2000 return err; //no need to catch this error
2003 TTimeToPost timeToPost = (TTimeToPost)IsTimeToPost(pic, delta);
2008 iPostingTimer->Cancel();
2015 RemoveFromQ(); // remove the pic that was returned by PeekQ
2016 if(iIsColorConversionNeeded)
2018 TVideoPicture* ccPic;
2019 ccPic = DoColorConvert(pic); // output will be in ccPic
2023 #ifdef _DUMP_YUV_FRAMES
2026 TInt err = iSessionManager->PostPicture(iSurfaceId, GetID(pic), ETrue);
2029 iProcessQ.Append(pic);
2030 iCurrentPlaybackPosition = pic->iTimestamp;
2031 if(!iFirstPictureUpdated)
2033 iFirstPictureUpdated = ETrue;
2034 if(!iSurfaceCreatedEventPublished)
2036 PublishSurfaceCreated();
2042 ReleasePicture(pic);
2051 ReleasePicture(pic);
2057 // get the next picture
2061 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AttemptToPost --"), this);
2065 TInt CNGAPostProcHwDevice::IsTimeToPost(TVideoPicture* frame, TInt64& delta)
2067 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost ++"), this);
2071 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost FAILED: Invalid frame ptr."), this);
2075 TInt resp = EPostIt;
2076 // Frame presentation time
2077 TInt64 uPresTime = frame->iTimestamp.Int64();
2079 // Check if this is an out of order frame in case of forward playback
2080 if((iCurrentPlaybackPosition.Int64() > uPresTime) && (iPlayRate > 0))
2082 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost : Out of order frame (forward playback) Tfm=%d"), this,(TInt)uPresTime);
2083 resp = ESkipIt; //drop
2084 } // Check if this is an out of order frame in case of backward playback
2085 else if((iCurrentPlaybackPosition.Int64() < uPresTime) && (iPlayRate < 0))
2087 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost : Out of order frame (backward playback) Tfm=%d"), this,(TInt)uPresTime);
2088 resp = ESkipIt; //drop
2090 else if (iClockSource)
2092 // The time to sync with.
2093 TInt64 uSyncTime = iClockSource->Time().Int64();
2095 delta = uPresTime - uSyncTime;
2096 if (( delta > KRenderAhead ) && (iPlayRate > 0)) // Delay condition not checked for
2097 { // backward playback
2098 resp = EDelayIt; //wait
2100 else if ( (delta < (-KMaxRenderDelay) && (iPlayRate > 0))
2101 || ((delta > KMaxRenderDelay) && (iPlayRate < 0)))
2103 resp = ESkipIt; //drop
2105 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost .. Tfm=%d, Tcs=%d, delta=%d"), this, (TInt)uPresTime, (TInt)uSyncTime, (TInt)delta);
2108 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost -- %d BufID = %d"), this, resp, GetID(frame));
2112 void CNGAPostProcHwDevice::ReleaseInputQ()
2114 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputQ ++ Q = %d"), this, iInputQ.Count());
2115 while (iInputQ.Count()>0)
2117 ReleasePicture(iInputQ[0]);
2120 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputQ --"), this);
2123 void CNGAPostProcHwDevice::ReleaseProcessQ()
2125 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseProcessQ ++ Q = %d"), this, iProcessQ.Count() );
2126 TVideoPicture* pic = NULL;
2128 while (iProcessQ.Count()>0)
2131 iProcessQ.Remove(0);
2132 ReturnPicToDecoder(pic);
2134 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseProcessQ --"), this);
2137 void CNGAPostProcHwDevice::ReleasePicture(TVideoPicture *pic)
2139 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleasePicture ++"), this);
2142 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputPicture FAILED: Invalid pic ptr."), this);
2146 if (iInputDecoderDevice)
2148 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputPicture .. before return picture. 2"), this);
2149 iInputDecoderDevice->ReturnPicture(pic);
2153 iVBMBufferQ.Append(pic);
2155 if ( !iIsInputEnded && iPPState != EStopped )
2157 iVBMObserver->MmvbmoNewBuffers();
2160 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleasePicture --"), this);
2163 void CNGAPostProcHwDevice::PublishSurfaceCreated()
2165 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PublishSurfaceCreated ++"), this);
2166 if(iVideoSurfaceObserver)
2168 iVideoSurfaceObserver->MmvsoSurfaceCreated();
2169 iSurfaceCreatedEventPublished = ETrue;
2171 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PublishSurfaceCreated --"), this);
2174 TInt CNGAPostProcHwDevice::SetupSurface()
2176 TInt err = KErrNone;
2177 if(iVBMEnabled && iVBMObserver)
2179 SetSurfaceAttributes(iVBMBufferOptions.iBufferSize, iVBMBufferOptions.iNumInputBuffers);
2181 err = iSurfaceHandler->CreateSurface(iAttributes, iSurfaceId);
2182 if (err != KErrNone)
2184 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create Surface %d"), this, err);
2187 err = iSurfaceHandler->MapSurface(iSurfaceId, iChunk);
2188 if (err != KErrNone)
2190 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to map Surface %d"), this, err);
2191 iSurfaceHandler->DestroySurface(iSurfaceId);
2192 iSurfaceId = TSurfaceId::CreateNullId();
2195 err = iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo);
2196 if (err != KErrNone)
2198 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to get Surface info %d"), this, err);
2199 iSurfaceHandler->DestroySurface(iSurfaceId);
2200 iSurfaceId = TSurfaceId::CreateNullId();
2203 TRAP(err, CreateVBMBuffersL());
2204 if (err != KErrNone)
2206 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create VBM buffer %d"), this, err);
2207 iSurfaceHandler->DestroySurface(iSurfaceId);
2208 iSurfaceId = TSurfaceId::CreateNullId();
2212 if (err != KErrNone)
2214 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to AddHints %d"), this, err);
2217 err = RegisterSurface(iSurfaceId);
2218 if (err != KErrNone)
2220 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to RegisterSurface %d"), this, err);
2221 iSurfaceHandler->DestroySurface(iSurfaceId);
2222 iSurfaceId = TSurfaceId::CreateNullId();
2230 void CNGAPostProcHwDevice::SetSurfaceAttributes(const TSize& aSize, TInt aNumBuf)
2232 iAttributes().iSize = aSize; // size of the video frame
2233 iAttributes().iBuffers = aNumBuf;
2235 /* The stride needs to be calculated for the surface manager to know
2236 how much memory to allocate */
2238 if(iAttributes().iPixelFormat == EUidPixelFormatYUV_420Planar)
2240 iAttributes().iStride = aSize.iWidth * 3/2;
2241 iVideoFrameBufSize = aSize.iWidth * aSize.iHeight * 3/2;
2245 iAttributes().iStride = aSize.iWidth * 2;
2246 iVideoFrameBufSize = aSize.iWidth * aSize.iHeight * 2;
2249 if(iIsColorConversionNeeded)
2251 iAttributes().iBuffers = aNumBuf + KColorConversionBuffers;
2255 iAttributes().iBuffers = aNumBuf;
2258 iAttributes().iOffsetToFirstBuffer = 0;
2259 #if defined __WINSCW__
2260 iAttributes().iAlignment = 4;
2261 #else //on hw, its always better to have page aligned chunks
2262 iAttributes().iAlignment = -1;
2264 iAttributes().iContiguous = ETrue;
2265 iAttributes().iHintCount = 0;
2266 iAttributes().iMappable = ETrue;
2269 TInt CNGAPostProcHwDevice::GetID(TVideoPicture *aPicture)
2271 if (iUsingExternalSurface)
2273 return GetExternalBufferID(aPicture);
2277 TUint8* aPtr = (TUint8*) aPicture->iData.iRawData->Ptr();
2278 return( (TInt) ((aPtr - iChunk.Base() - iAttributes().iOffsetToFirstBuffer) /
2279 (iVideoFrameBufSize )));
2283 TInt CNGAPostProcHwDevice::GetExternalBufferID(TVideoPicture *aPicture)
2285 // currently type cast the pointer as buffer ID.
2286 // FIXME once the new data structure is available.
2287 return( (TInt) aPicture->iData.iRawData->Ptr());
2290 TInt CNGAPostProcHwDevice::RegisterSurface(const TSurfaceId& aSurfaceId)
2292 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:RegisterSurface(): RegisterSurface ID = 0x%x"), this, aSurfaceId);
2293 TInt err = KErrNone;
2294 TInt numScreens = iWsSession.NumberOfScreens();
2295 for(TInt i=0; (i < numScreens && err == KErrNone); i++)
2297 err = iWsSession.RegisterSurface(i, aSurfaceId);
2302 TInt CNGAPostProcHwDevice::IsGceReady()
2304 if(iProcessQ.Count() >= KMaxBuffersGceCanHold)
2311 void CNGAPostProcHwDevice::SetTimer(TInt64 aDelta)
2313 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetTimer .. aDelta=%d"), this, (TInt)aDelta);
2314 if(aDelta <= KRenderAhead)
2318 iPostingTimer->After(aDelta * -1);
2322 iPostingTimer->After((aDelta - KRenderAhead) * -1);
2327 iPostingTimer->After(aDelta - KRenderAhead - KPostingOfset);
2331 // Convert YUV420 to YUV422InterLeaved.
2333 TInt CNGAPostProcHwDevice::ConvertPostProcBuffer(TVideoPicture* pSrc, TVideoPicture* pDest)
2335 PP_DEBUG(_L("CMdfPostingSurfaceProxy::ConvertPostProcBuffer ++"));
2336 TInt err = KErrNone;
2337 if (!pDest && !pSrc)
2339 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ConvertPostProcBuffer FAILED: Invalid pic pSrc %x pDest %x."), this, pSrc, pDest);
2340 return KErrArgument;
2343 // --- Prepare wrappers ---
2344 tBaseVideoFrame tFrame420, tFrame422;
2345 TInt frameSize = pSrc->iData.iDataSize.iWidth * pSrc->iData.iDataSize.iHeight;
2347 PP_DEBUG(_L("CMdfPostingSurfaceProxy::ConvertPostProcBuffer .. w=%d, h=%d"), pSrc->iData.iDataSize.iWidth, pSrc->iData.iDataSize.iHeight);
2349 tFrame420.width = pSrc->iData.iDataSize.iWidth;
2350 tFrame420.height= pSrc->iData.iDataSize.iHeight;
2351 tFrame420.lum = (TUint8*)pSrc->iData.iRawData->Ptr();
2352 tFrame420.cb = (TUint8*)tFrame420.lum + frameSize;
2353 tFrame420.cr = (TUint8*)tFrame420.lum + (frameSize*5)/4;
2355 tFrame422.width = pSrc->iData.iDataSize.iWidth;
2356 tFrame422.height= pSrc->iData.iDataSize.iHeight;
2357 tFrame422.lum = (TUint8*)pDest->iData.iRawData->Ptr();
2361 // --- Convertion to posting buffer ---
2362 TInt stride = pSrc->iData.iDataSize.iWidth * 2;
2363 EBufferLayout422 layout = YUV422INT_BE;
2365 err = gColorConvYUVtoYUV422Int(&tFrame420, &tFrame422, layout, stride);
2368 PP_DEBUG(_L("CNGAPostProcHwDevice::ConvertPostProcBuffer .. err= %d."), err);
2373 void CNGAPostProcHwDevice::AddPictureToVBMQ(TVideoPicture *pic)
2375 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddPictureToVBMQ ++"), this);
2376 iVBMBufferQ.Append(pic);
2378 if ( !iIsInputEnded && iPPState != EStopped )
2380 iVBMObserver->MmvbmoNewBuffers();
2383 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddPictureToVBMQ --"), this);
2386 void CNGAPostProcHwDevice::AddPictureToColorConversionQ(TVideoPicture *pic)
2388 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddPictureToColorConversionQ ++"), this);
2389 iColorConversionQ.Append(pic);
2390 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddPictureToColorConversionQ --"), this);
2393 #ifdef _DUMP_YUV_FRAMES
2394 void CNGAPostProcHwDevice::captureYuv(TVideoPicture* aPicture)
2397 sprintf(buf, "c:\\fb%d.yuv", count++);
2398 FILE *fp = ::fopen(buf, "w");
2399 TInt size = aPicture->iData.iRawData->Size();
2400 //{FILE* f1 = fopen(MY_LOG_FILE_NAME, "a+"));if(f1){fprintf(f1, "Size %d \n"), size );fclose(f1); }}
2402 ::fwrite(aPicture->iData.iRawData->Ptr(), 1, size, fp);
2407 void CNGAPostProcHwDevice::ResetCountingBuffer()
2409 memset(iSkippedFramesCountingBuffer,0,sizeof(iSkippedFramesCountingBuffer));
2410 iSkippedFramesInLast64Frames = 0;
2411 iCurrentPosInFramesCountingBuffer = 0;
2414 void CNGAPostProcHwDevice::PicturesSkipped()
2416 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PicturesSkipped ++"), this);
2417 iPictureCounters.iPicturesSkipped++;
2418 if (!iKeyFrameMode && iPlayRate>KDefPlayRate)
2420 if (iSkippedFramesCountingBuffer[iCurrentPosInFramesCountingBuffer]==0)
2422 iSkippedFramesCountingBuffer[iCurrentPosInFramesCountingBuffer] = 1;
2423 iSkippedFramesInLast64Frames++;
2424 if (iSkippedFramesInLast64Frames>KMaxAllowedSkipInNFrames && iFPObserver )
2426 iFPObserver->MmvproKeyFrameModeRequest();
2427 iKeyFrameMode=ETrue;
2428 ResetCountingBuffer();
2431 iCurrentPosInFramesCountingBuffer = ++iCurrentPosInFramesCountingBuffer%64;
2433 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PicturesSkipped --"), this);
2436 TVideoPicture* CNGAPostProcHwDevice::DoColorConvert(TVideoPicture* aPicture)
2438 TVideoPicture *pOutPicture = aPicture;
2440 if(iColorConversionQ.Count())
2442 pOutPicture = iColorConversionQ[0];
2443 iColorConversionQ.Remove(0);
2444 ConvertPostProcBuffer(aPicture, pOutPicture);
2445 pOutPicture->iTimestamp = aPicture->iTimestamp;
2446 ReleasePicture(aPicture);
2450 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: color conversion"), this);
2456 TInt CNGAPostProcHwDevice::AddToQ(TVideoPicture* aPicture)
2458 TVideoPicture* pic = aPicture;
2460 if(iInputQ.Count() == 0)
2462 iInputQ.Append(pic);
2466 pos = iInputQ.Count()-1;
2467 for(; pos >= 0; pos--)
2469 if(pic->iTimestamp.Int64() > iInputQ[pos]->iTimestamp.Int64())
2474 if(iInputQ.Count() == pos+1)
2476 iInputQ.Append(pic);
2480 iInputQ.Insert(pic, pos+1);
2486 void CNGAPostProcHwDevice::RemoveFromQ()
2496 iInputQ.Remove(iInputQ.Count()-1);
2501 TVideoPicture* CNGAPostProcHwDevice::PeekQ()
2503 TVideoPicture *pic = NULL;
2512 pic = iInputQ[iInputQ.Count()-1];
2518 TInt CNGAPostProcHwDevice::AddHints()
2520 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints iSurfaceMask 0x%08x ++"), this, iSurfaceMask);
2521 TInt err = KErrNone;
2522 iHint.Set(iSurfaceKey,iSurfaceMask,ETrue);
2523 err = iSurfaceHandler->AddSurfaceHint(iSurfaceId,iHint);
2524 if(err == KErrAlreadyExists)
2527 err = iSurfaceHandler->SetSurfaceHint(iSurfaceId,iHint);
2529 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints. err = %d --"), this,err);
2530 iHint.iKey.iUid = surfaceHints::KSurfaceContent;
2531 iHint.iValue = surfaceHints::EVideoPlayback;
2532 iHint.iMutable = ETrue;
2533 err = iSurfaceHandler->AddSurfaceHint(iSurfaceId,iHint);
2534 if(err == KErrAlreadyExists)
2537 err = iSurfaceHandler->SetSurfaceHint(iSurfaceId,iHint);
2539 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints. err = %d --"), this,err);
2543 TInt CNGAPostProcHwDevice::ColorConvert(tBaseVideoFrame* aInputFrame, TUint8* aDestPtr, tWndParam* aInputCropWindow, tWndParam* aOutputCropWindow)
2545 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ColorConvert ++"), this);
2546 __ASSERT_ALWAYS(aDestPtr, User::Invariant());
2547 TInt lError = E_SUCCESS;
2548 TInt err = KErrNone;
2550 err = SetSourceFormat();
2553 err = SetSourceRange();
2557 lError = Emz_VDec_gColorConv_YUVtoRGB(aInputFrame,aDestPtr,
2558 aInputCropWindow, aOutputCropWindow, iSourceFormat,
2559 EBitmapColor16MU, iSourceRange);
2563 if(lError == E_OUT_OF_MEMORY)
2567 else if(lError == E_FAILURE)
2569 err = KErrNotSupported;
2579 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ColorConvert --"), this);
2583 TInt CNGAPostProcHwDevice::SetSourceFormat()
2585 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceFormatL ++"), this);
2586 TInt err = KErrNone;
2587 switch (iVideoFormat.iYuvFormat.iPattern)
2589 case EYuv420Chroma1:
2590 iSourceFormat = EYuv420Chroma1_Planar;
2592 case EYuv420Chroma2:
2593 iSourceFormat = EYuv420Chroma2_Planar;
2595 case EYuv420Chroma3:
2596 iSourceFormat = EYuv420Chroma3_Planar;
2598 case EYuv422Chroma1:
2599 if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedLE)
2600 iSourceFormat = EYuv422Chroma1_LE;
2601 else if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedBE )
2602 iSourceFormat = EYuv422Chroma1_BE;
2606 case EYuv422Chroma2:
2607 if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedLE)
2608 iSourceFormat = EYuv422Chroma2_LE;
2609 else if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedBE )
2610 iSourceFormat = EYuv422Chroma2_BE;
2615 err = KErrNotSupported;
2617 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceFormatL --"), this);
2622 TInt CNGAPostProcHwDevice::SetSourceRange()
2624 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceRangeL ++"), this);
2625 TInt err = KErrNone;
2626 switch (iVideoFormat.iYuvFormat.iCoefficients)
2628 case EYuvBt601Range0:
2629 iSourceRange = EITU601_5_REDUCEDRANGE;
2631 case EYuvBt601Range1:
2632 iSourceRange = EITU601_5_FULLRANGE;
2634 case EYuvBt709Range0:
2635 iSourceRange = EB709_REDUCEDRANGE;
2637 case EYuvBt709Range1:
2638 iSourceRange = EB709_FULLRANGE;
2641 err = KErrNotSupported;
2643 PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceRangeL --"), this);
2647 CNGAPostProcTimer::CNGAPostProcTimer( CNGAPostProcHwDevice& aParent )
2648 :CTimer(EPriorityHigh),iParent(aParent)
2650 CActiveScheduler::Add(this);
2653 CNGAPostProcTimer::~CNGAPostProcTimer()
2655 PP_DEBUG(_L("CNGAPostProcTimer[%x]:~CNGAPostProcTimer ++"), this);
2657 PP_DEBUG(_L("CNGAPostProcTimer[%x]:~CNGAPostProcTimer --"), this);
2660 CNGAPostProcTimer* CNGAPostProcTimer::NewL( CNGAPostProcHwDevice& aParent )
2662 CNGAPostProcTimer* self = new (ELeave)CNGAPostProcTimer(aParent);
2663 CleanupStack::PushL( self );
2665 CleanupStack::Pop( self );
2669 void CNGAPostProcTimer::ConstructL()
2671 CTimer::ConstructL();
2674 void CNGAPostProcTimer::RunL()
2676 PP_DEBUG(_L("CNGAPostProcTimer[%x]:RunL ++"), this);
2677 if (iStatus ==KErrCancel)
2679 PP_DEBUG(_L("CNGAPostProcNotifier[%x]:CNGAPostProcNotifier:RunL State canceled"), this);
2682 iParent.AttemptToPost();
2683 PP_DEBUG(_L("CNGAPostProcTimer[%x]:RunL --"), this);
2686 void CNGAPostProcHwDevice::MmpirPostInitializeRequest(MMmfPostInitializeResponse& aResponse)
2688 iPostInitializeResponse = &aResponse;