sl@0: /* sl@0: * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include "NGAPostProcHwDevice.h" sl@0: #include "NGAPostProcSessionManager.h" sl@0: #include "NGAPostProcSurfaceHandler.h" sl@0: sl@0: //currently this uid only used if not under WINSCW environment since the only hw to use is bridge sl@0: #define EStUidPixelFormatYUV_420MB 0x2001FBC1 sl@0: // post-processor info sl@0: const TUid KUidVideoPostProcHwDevice = {KUidNGAPostProcHwDeviceImplUid}; sl@0: _LIT(KManufacturer, "Nokia Inc."); sl@0: _LIT(KIdentifier, "Nokia S60 Video Post Processor Hardware Device Plugin"); sl@0: sl@0: // --- Constants --- sl@0: const TInt KMaxVBMBuffers = 4; sl@0: const TInt KMinVBMInputWidth = 32; sl@0: const TInt KMinVBMInputHeight = 32; sl@0: const TInt KMaxVBMInputWidth = 1280; sl@0: const TInt KMaxVBMInputHeight = 720; sl@0: const TInt KRenderAhead = 50000; sl@0: const TInt KMaxRenderDelay = 50000; sl@0: const TInt KPostingOfset = 0; sl@0: const TInt KColorConversionBuffers = 3; sl@0: const TInt KMaxBuffersGceCanHold = 3; sl@0: const TInt KDefPlayRate = 100; sl@0: const TInt KMaxAllowedSkipInNFrames = 40; sl@0: #ifdef __cplusplus sl@0: extern "C" sl@0: { sl@0: #endif sl@0: sl@0: int32 gColorConvYUVtoYUV422Int (tBaseVideoFrame *yuv420Frame, tBaseVideoFrame* yuv422Frame, sl@0: uint8 outClrFmt, int16 stride); sl@0: sl@0: int32 Emz_VDec_gColorConv_YUVtoRGB ( sl@0: tBaseVideoFrame *srcImage, uint8 *dstImage, tWndParam *srcWindow, sl@0: tWndParam *dstWindow, uint8 srcImageFormat, uint8 dstImageFormat, sl@0: uint8 colorConvScheme); sl@0: sl@0: #ifdef __cplusplus sl@0: } sl@0: #endif sl@0: sl@0: //************************************************** sl@0: sl@0: CMMFVideoPostProcHwDevice* CNGAPostProcHwDevice::NewL() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice::NewL() ++")); sl@0: sl@0: CNGAPostProcHwDevice* self = new (ELeave) CNGAPostProcHwDevice; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice::NewL() --")); sl@0: return (CMMFVideoPostProcHwDevice*)self; sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::ConstructL() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::ConstructL() ++"), this); sl@0: sl@0: // support for VBM buffer interface sl@0: iVBMBufferOptions.iNumInputBuffers = KMaxVBMBuffers; sl@0: iVBMBufferOptions.iBufferSize = TSize(KMaxVBMInputWidth, KMaxVBMInputHeight); sl@0: iPostingTimer = CNGAPostProcTimer::NewL(*this); sl@0: User::LeaveIfError(iWsSession.Connect()); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::ConstructL() --"), this); sl@0: } sl@0: sl@0: CNGAPostProcHwDevice::CNGAPostProcHwDevice() sl@0: : iProxy(NULL), sl@0: iInputDecoderDevice(NULL), sl@0: iCurrentPlaybackPosition(TTimeIntervalMicroSeconds(0)), sl@0: iPPState(EInitializing), sl@0: iSurfaceHandler(NULL), sl@0: iSessionManager(NULL), sl@0: iIsInputEnded(EFalse), sl@0: iPostingTimer(NULL), sl@0: iFirstPictureUpdated(EFalse), sl@0: iUsingExternalSurface(EFalse), sl@0: iIsColorConversionNeeded(EFalse), sl@0: iSurfaceCreatedEventPublished(EFalse), sl@0: iOverflowPictureCounter(0), sl@0: iVideoFrameBufSize(0), sl@0: iResourceLost(EFalse), sl@0: iRedrawDone(EFalse), sl@0: iRedrawSurfaceInUse(EFalse), sl@0: iVBMObserver(NULL), sl@0: iVBMEnabled(EFalse), sl@0: count(0), sl@0: iSurfaceMask(surfaceHints::EAllowAllExternals), sl@0: iSurfaceKey(TUid::Uid(surfaceHints::KSurfaceProtection)), sl@0: iVideoSurfaceObserver(NULL), sl@0: iVPObserver(NULL), sl@0: iPicSize(0,0), sl@0: iAspectRatioNum(1), sl@0: iAspectRatioDenom(1), sl@0: iStepFrameCount(0), sl@0: iPlayRate(KDefPlayRate), sl@0: iKeyFrameMode(EFalse), sl@0: iFPObserver(NULL), sl@0: iIsExternalChunk(EFalse) sl@0: { sl@0: iSurfaceId = TSurfaceId::CreateNullId(); sl@0: sl@0: #if defined __WINSCW__ sl@0: iAttributes().iPixelFormat = EUidPixelFormatYUV_422Interleaved; sl@0: #else sl@0: iAttributes().iPixelFormat = (TUidPixelFormat) EStUidPixelFormatYUV_420MB; sl@0: #endif sl@0: } sl@0: sl@0: CNGAPostProcHwDevice::~CNGAPostProcHwDevice() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::~CNGAPostProcHwDevice() ++"), this); sl@0: if (iSessionManager) sl@0: { sl@0: iSessionManager->CancelNotifiers(); sl@0: delete iSessionManager; sl@0: iSessionManager = NULL; sl@0: } sl@0: sl@0: while (iSupportedInputFormats.Count()>0) sl@0: { sl@0: iSupportedInputFormats.Remove(0); sl@0: } sl@0: sl@0: while (iProcessQ.Count()>0) sl@0: { sl@0: iProcessQ.Remove(0); sl@0: } sl@0: sl@0: if(iPostingTimer) sl@0: { sl@0: iPostingTimer->Cancel(); sl@0: delete iPostingTimer; sl@0: iPostingTimer = NULL; sl@0: } sl@0: sl@0: while (iVBMBufferReferenceQ.Count()>0) sl@0: { sl@0: TVideoPicture* pic = iVBMBufferReferenceQ[0]; sl@0: iVBMBufferReferenceQ.Remove(0); sl@0: if (iColorConversionQ.Count()>0) sl@0: { sl@0: iColorConversionQ.Remove(0); sl@0: } sl@0: sl@0: if (pic->iHeader) delete pic->iHeader; sl@0: delete pic->iData.iRawData; sl@0: delete pic; sl@0: } sl@0: sl@0: iSupportedInputFormats.Reset(); sl@0: iSupportedInputFormats.Close(); sl@0: sl@0: iVBMBufferReferenceQ.Reset(); sl@0: iVBMBufferReferenceQ.Close(); sl@0: sl@0: iColorConversionQ.Reset(); sl@0: iColorConversionQ.Close(); sl@0: sl@0: iVBMBufferQ.Reset(); sl@0: iVBMBufferQ.Close(); sl@0: sl@0: iProcessQ.Reset(); sl@0: iProcessQ.Close(); sl@0: sl@0: iInputQ.Reset(); sl@0: iInputQ.Close(); sl@0: sl@0: if (iSurfaceHandler) sl@0: { sl@0: if(!iSurfaceId.IsNull()) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::UnregisterSurface"), this); sl@0: TInt numScreens = iWsSession.NumberOfScreens(); sl@0: for(TInt i=0;i < numScreens;i++) sl@0: { sl@0: iWsSession.UnregisterSurface(i, iSurfaceId); sl@0: } sl@0: iWsSession.Flush(); sl@0: TInt err = iSurfaceHandler->DestroySurface(iSurfaceId); sl@0: } sl@0: delete iSurfaceHandler; sl@0: iSurfaceHandler = NULL; sl@0: } sl@0: sl@0: iWsSession.Close(); sl@0: if(!iIsExternalChunk) sl@0: { sl@0: iChunk.Close(); sl@0: } sl@0: sl@0: RDebug::Printf("------ Statistics of Post Processor ------"); sl@0: RDebug::Printf(" Pictures Received : %d", iPictureCounters.iTotalPictures); sl@0: RDebug::Printf(" Pictures Displayed: %d", iPictureCounters.iPicturesDisplayed); sl@0: RDebug::Printf(" Pictures Skipped : %d", iPictureCounters.iPicturesSkipped); sl@0: RDebug::Printf(" Pictures overflow : %d", iOverflowPictureCounter); sl@0: RDebug::Printf("------------------------------------------"); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:~() --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetInputFormatL(const TUncompressedVideoFormat& aFormat) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputFormatL() Pattern= %x ++"), this, aFormat.iYuvFormat.iPattern); sl@0: if (iPPState != EInitializing) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputFormatL() FAILED: Unexpected state"), this); sl@0: User::Leave(KErrNotReady); sl@0: } sl@0: sl@0: iVideoFormat = aFormat; sl@0: if( ((iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma1) || sl@0: (iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma2) || sl@0: (iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma3) )) sl@0: { sl@0: iVideoFormat.iYuvFormat.iCoefficients = EYuvBt709Range1; sl@0: iVideoFormat.iYuvFormat.iPattern = EYuv422Chroma1; sl@0: iVideoFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedBE; sl@0: sl@0: #if defined __WINSCW__ sl@0: iIsColorConversionNeeded = ETrue; sl@0: #else sl@0: iAttributes().iPixelFormat = (TUidPixelFormat) EStUidPixelFormatYUV_420MB; sl@0: #endif sl@0: } sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputFormatL() WARNING: -- Not Found!"), this); sl@0: } sl@0: sl@0: sl@0: void CNGAPostProcHwDevice::SetInputDevice(CMMFVideoDecodeHwDevice* aDevice) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputDevice() ++"), this); sl@0: sl@0: if (iPPState != EInitializing) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputDevice() FAILED: unexpected state"), this); sl@0: return; sl@0: } sl@0: sl@0: iInputDecoderDevice = aDevice; sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputDevice() --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::GetOutputFormatListL(RArray& ) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetOutputFormatListL() ++"), this); sl@0: sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetOutputFormatListL() --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetOutputFormatL(const TUncompressedVideoFormat& ) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetOutputFormatL() ++"), this); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetOutputFormatL() --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetClockSource(MMMFClockSource* aClock) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetClockSource() ++"), this); sl@0: sl@0: if (iPPState != EInitializing) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetClockSource() FAILED: Unexpected state"), this); sl@0: return; sl@0: } sl@0: iClockSource = aClock; sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetClockSource() --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetVideoDestScreenL(TBool /*aScreen*/) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetVideoDestScreenL() ++"), this); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetVideoDestScreenL() --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetProxy(MMMFDevVideoPlayProxy& aProxy) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetProxy() ++"), this); sl@0: sl@0: if (iPPState != EInitializing) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetProxy() FAILED: Unexpected state"), this); sl@0: return; sl@0: } sl@0: sl@0: iProxy = &aProxy; sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetProxy() --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::Initialize() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize ++")); sl@0: TInt err = KErrNone; sl@0: sl@0: if (iPPState != EInitializing) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize() FAILED: Unexpected state"), this); sl@0: if (iProxy) sl@0: { sl@0: iProxy->MdvppInitializeComplete(this, KErrNotReady); sl@0: } sl@0: return; sl@0: } sl@0: if (!iSurfaceHandler) sl@0: { sl@0: TRAP(err, iSurfaceHandler = CNGAPostProcSurfaceHandler::NewL()); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create SurfaceHandler."), this); sl@0: if (iProxy) sl@0: { sl@0: iProxy->MdvppInitializeComplete(this, err); sl@0: } sl@0: return; sl@0: } sl@0: } sl@0: if (!iSessionManager) sl@0: { sl@0: TRAP(err, iSessionManager = CNGAPostProcSessionManager::NewL()); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create SessionManager."), this); sl@0: if (iProxy) sl@0: { sl@0: iProxy->MdvppInitializeComplete(this, err); sl@0: } sl@0: return; sl@0: } sl@0: iSessionManager->SetObserver(*this); sl@0: } sl@0: sl@0: if (iInputDecoderDevice) sl@0: { sl@0: MMmfVideoResourceHandler* handler = NULL; sl@0: handler = (MMmfVideoResourceHandler*)iInputDecoderDevice->CustomInterface(KUidMmfVideoResourceManagement); sl@0: if (handler) sl@0: { sl@0: handler->MmvrhSetObserver((MMmfVideoResourceObserver*)this); sl@0: } sl@0: else sl@0: { sl@0: PP_DEBUG(_L("ppHwDev[%x]:Initialize() decoder yet to implement MMmfVideoResourceHandler CI"), this); sl@0: } sl@0: sl@0: MMmfVideoPropertiesNotifier* VPHandler = NULL; sl@0: VPHandler = (MMmfVideoPropertiesNotifier*)iInputDecoderDevice->CustomInterface(KUidMmfVideoPropertiesManagement); sl@0: if (VPHandler) sl@0: { sl@0: PP_DEBUG(_L("ppHwDev[%x]:Initialize() Register for video property changes"), this); sl@0: VPHandler->MmvpnSetObserver((MMmfVideoPropertiesObserver*)this); sl@0: } sl@0: else sl@0: { sl@0: PP_DEBUG(_L("ppHwDev[%x]:Initialize() decoder yet to implement MMmfVideoPropertiesNotifier CI"), this); sl@0: } sl@0: } sl@0: sl@0: // Initialize picture counters sl@0: iPictureCounters.iPicturesSkipped = 0; sl@0: iPictureCounters.iPicturesDisplayed = 0; sl@0: iPictureCounters.iTotalPictures = 0; sl@0: iOverflowPictureCounter = 0; sl@0: sl@0: iPPState = EInitialized; sl@0: if(iPostInitializeResponse) sl@0: { sl@0: sl@0: TRAP(err, iPostInitializeResponse->MmpirPostInitializeResponseL()); sl@0: } sl@0: sl@0: if(!err) sl@0: { sl@0: TRAP(err, iSessionManager->CreateNotifierL(iInfo().iBuffers)); sl@0: } sl@0: else sl@0: { sl@0: iPPState = EInitializing; sl@0: } sl@0: sl@0: if (iProxy) sl@0: { sl@0: iProxy->MdvppInitializeComplete(this, err); sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::WritePictureL(TVideoPicture* aPicture) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePicture bufId = %d"), this,GetID(aPicture)); sl@0: TVideoPicture* pic; sl@0: if (iPPState==EInitializing || iPPState==EStopped || iIsInputEnded) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: Unexpected state"), this); sl@0: User::Leave(KErrNotReady); sl@0: } sl@0: sl@0: if(!aPicture) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: Invalid argument"), this); sl@0: User::Leave(KErrArgument); sl@0: } sl@0: pic = aPicture; sl@0: iPictureCounters.iTotalPictures++; sl@0: if((iPPState != EPlaying) && (iFirstPictureUpdated)) sl@0: { sl@0: //If decoder is fast enough, it can happen between Initialize->Start time gap between sl@0: //DecodeHwDevice and PostProc_HwDevice. OR between Pause->Resume time gap as well. sl@0: AddToQ(pic); sl@0: } sl@0: else if( iInputQ.Count() > 0 ) sl@0: { sl@0: AddToQ(pic); sl@0: AttemptToPost(); sl@0: } sl@0: else sl@0: { sl@0: TTimeToPost timeToPost = EPostIt; sl@0: TInt64 delta = 0; sl@0: if(iFirstPictureUpdated) sl@0: { sl@0: timeToPost = (TTimeToPost)IsTimeToPost(pic, delta); sl@0: if(!IsGceReady()) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL GCE not ready"), this ); sl@0: if(timeToPost == EPostIt) sl@0: { sl@0: timeToPost = EDelayIt; sl@0: } sl@0: } sl@0: if (delta > 0x7FFFFFFF) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL Too large delta .. skipping"), this ); sl@0: timeToPost = ESkipIt; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: if(!iSurfaceCreatedEventPublished) sl@0: { sl@0: PublishSurfaceCreated(); sl@0: } sl@0: iFirstPictureUpdated = ETrue; sl@0: } sl@0: sl@0: sl@0: switch(timeToPost) sl@0: { sl@0: case EDelayIt: sl@0: { sl@0: if(AddToQ(pic) != 0) sl@0: { sl@0: break; sl@0: } sl@0: iPostingTimer->Cancel(); sl@0: SetTimer(delta); sl@0: } sl@0: break; sl@0: case EPostIt: sl@0: { sl@0: sl@0: if(iIsColorConversionNeeded) sl@0: { sl@0: TVideoPicture* ccPic; sl@0: ccPic = DoColorConvert(pic); // output will be in ccPic sl@0: pic = ccPic; sl@0: } sl@0: sl@0: #ifdef _DUMP_YUV_FRAMES sl@0: captureYuv(pic); sl@0: #endif sl@0: TInt err = iSessionManager->PostPicture(iSurfaceId, GetID(pic), ETrue); sl@0: if(err == KErrNone) sl@0: { sl@0: iProcessQ.Append(pic); sl@0: iCurrentPlaybackPosition = pic->iTimestamp; sl@0: } sl@0: else sl@0: { sl@0: ReleasePicture(pic); sl@0: } sl@0: } sl@0: break; sl@0: case ESkipIt: sl@0: { sl@0: ReleasePicture(pic); sl@0: PicturesSkipped(); sl@0: } sl@0: break; sl@0: } sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePicture --"), this); sl@0: } sl@0: sl@0: sl@0: CPostProcessorInfo* sl@0: CNGAPostProcHwDevice::PostProcessorInfoLC() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PostProcessorInfoLC() ++"), this); sl@0: TUncompressedVideoFormat yuvFormat; sl@0: RArray SupportedPostProcess; sl@0: TBool SupportedHwAcceleration = ETrue; //Non-Accelerated ETrue, sl@0: TYuvToRgbCapabilities SupportedYuvToRgbCapab; sl@0: TInt32 SupportedRotations = ERotateNone; // no rotation supported sl@0: sl@0: TBool SupportedArbitraryScaling = EFalse; // no scaling supported sl@0: RArray SupportedScaleFactors; sl@0: TBool SupportedAntiAliasing = EFalse; sl@0: sl@0: //default sl@0: yuvFormat.iDataFormat = EYuvRawData; sl@0: yuvFormat.iYuvFormat.iYuv2RgbMatrix = 0; sl@0: yuvFormat.iYuvFormat.iRgb2YuvMatrix = 0; sl@0: yuvFormat.iYuvFormat.iAspectRatioNum = 1; sl@0: yuvFormat.iYuvFormat.iAspectRatioDenom = 1; sl@0: yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range1; sl@0: yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1; sl@0: yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedBE; sl@0: sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range0; sl@0: yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1; sl@0: yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedBE; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range0; sl@0: yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1; sl@0: yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedLE; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range1; sl@0: yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1; sl@0: yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedLE; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range0; sl@0: yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1; sl@0: yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedBE; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range1; sl@0: yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1; sl@0: yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedBE; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range0; sl@0: yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1; sl@0: yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedLE; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range1; sl@0: yuvFormat.iYuvFormat.iPattern = EYuv422Chroma1; sl@0: yuvFormat.iYuvFormat.iDataLayout = EYuvDataInterleavedLE; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iPattern = EYuv422Chroma2; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: //YUV 420 planar sl@0: yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range1; sl@0: yuvFormat.iYuvFormat.iPattern = EYuv420Chroma1; sl@0: yuvFormat.iYuvFormat.iDataLayout = EYuvDataPlanar; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iPattern = EYuv420Chroma2; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iPattern = EYuv420Chroma3; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iCoefficients = EYuvBt709Range0; sl@0: yuvFormat.iYuvFormat.iPattern = EYuv420Chroma1; sl@0: yuvFormat.iYuvFormat.iDataLayout = EYuvDataPlanar; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iPattern = EYuv420Chroma2; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iPattern = EYuv420Chroma3; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range1; sl@0: yuvFormat.iYuvFormat.iPattern = EYuv420Chroma1; sl@0: yuvFormat.iYuvFormat.iDataLayout = EYuvDataPlanar; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iPattern = EYuv420Chroma2; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iPattern = EYuv420Chroma3; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iCoefficients = EYuvBt601Range0; sl@0: yuvFormat.iYuvFormat.iPattern = EYuv420Chroma1; sl@0: yuvFormat.iYuvFormat.iDataLayout = EYuvDataPlanar; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iPattern = EYuv420Chroma2; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: yuvFormat.iYuvFormat.iPattern = EYuv420Chroma3; sl@0: User::LeaveIfError(iSupportedInputFormats.Append(yuvFormat)); sl@0: sl@0: CPostProcessorInfo* postProcessorInfo = CPostProcessorInfo::NewL( sl@0: KUidVideoPostProcHwDevice, sl@0: KManufacturer, sl@0: KIdentifier, sl@0: TVersion(1, 0, 0), sl@0: iSupportedInputFormats.Array(), sl@0: SupportedPostProcess.Array(), sl@0: SupportedHwAcceleration, sl@0: ETrue, //Direct Display sl@0: SupportedYuvToRgbCapab, sl@0: SupportedRotations, sl@0: SupportedArbitraryScaling, sl@0: SupportedScaleFactors.Array(), sl@0: SupportedAntiAliasing); sl@0: sl@0: CleanupStack::PushL(postProcessorInfo); sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PostProcessorInfoLC() --"), this); sl@0: return postProcessorInfo; sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::MmvprcGetPlayRateCapabilitiesL(TVideoPlayRateCapabilities& aCap) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcGetPlayRateCapabilitiesL ++"), this); sl@0: aCap.iPlayForward = ETrue; sl@0: aCap.iPlayBackward = ETrue; sl@0: aCap.iStepForward = ETrue; sl@0: aCap.iStepBackward = ETrue; sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcGetPlayRateCapabilitiesL --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::MmvprcSetPlayRateL(const TInt aRate) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcSetPlayRateL ++"), this); sl@0: iPlayRate = aRate; sl@0: if (iPlayRate<0) sl@0: { sl@0: iKeyFrameMode = ETrue; sl@0: } sl@0: else sl@0: { sl@0: iKeyFrameMode = EFalse; sl@0: ResetCountingBuffer(); sl@0: } sl@0: //In fast forward go direct to key frame mode if speed >4X = sl@0: if (iPlayRate>KDefPlayRate*4) sl@0: { sl@0: if (iFPObserver) sl@0: { sl@0: iFPObserver->MmvproKeyFrameModeRequest(); sl@0: iKeyFrameMode=ETrue; sl@0: } sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcSetPlayRateL=%d --"), this, aRate); sl@0: } sl@0: sl@0: TInt CNGAPostProcHwDevice::MmvprcPlayRateL() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcPlayRateL= ++"), this); sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcPlayRateL= --"), this); sl@0: return iPlayRate; sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::MmvprcStepFrameL(const TInt aStep) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcStepFrameL= ++"), this); sl@0: iStepFrameCount = aStep; sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcStepFrameL=%d --"), this, aStep); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::MmvprcSetObserver(MMmfVideoPlayRateObserver& aObserver) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcSetObserver ++"), this); sl@0: iFPObserver = &aObserver; sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvprcSetObserver --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::MmvsoSetSecureOutputL(TBool aSecure) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvsoSetSecureOutputL aSecure = %d++"), this, aSecure); sl@0: TInt err = KErrNone; sl@0: if(aSecure) sl@0: { sl@0: iSurfaceMask = surfaceHints::EAllowInternalOnly; sl@0: } sl@0: else sl@0: { sl@0: iSurfaceMask = surfaceHints::EAllowAllExternals; sl@0: } sl@0: if(!iSurfaceId.IsNull()) sl@0: { sl@0: err = AddHints(); sl@0: if(err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvsoSetSecureOutputL -- leaving err = %d"), this, err); sl@0: User::Leave(err); sl@0: } sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvsoSetSecureOutputL --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::MmavsoSetAllowedOutputL(TUint aAllowedOutputMask) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmavsoSetAllowedOutputL aAllowedOutputMask=0x%08x ++"), this,aAllowedOutputMask); sl@0: TInt err = KErrNone; sl@0: iSurfaceMask = surfaceHints::EAllowInternalOnly; sl@0: if (aAllowedOutputMask == EVideoAllowAll) sl@0: { sl@0: iSurfaceMask = surfaceHints::EAllowAllExternals; sl@0: } sl@0: else if (aAllowedOutputMask == EVideoAllowInternalOnly) sl@0: { sl@0: iSurfaceMask = surfaceHints::EAllowInternalOnly; sl@0: } sl@0: else sl@0: { sl@0: // we hope to find some valid output prefs sl@0: if (aAllowedOutputMask & EVideoAllowAnalog) sl@0: { sl@0: iSurfaceMask |= surfaceHints::EAllowAnalog; sl@0: } sl@0: if (aAllowedOutputMask & EVideoAllowMacroVision) sl@0: { sl@0: iSurfaceMask |= surfaceHints::EAllowAnalogProtectionRequired; sl@0: } sl@0: if (aAllowedOutputMask & EVideoAllowHDMI) sl@0: { sl@0: iSurfaceMask |= surfaceHints::EAllowDigital; sl@0: } sl@0: if (aAllowedOutputMask & EVideoAllowHdmiHdcpRequested) sl@0: { sl@0: iSurfaceMask |= surfaceHints::EAllowDigitalProtectionRequested; sl@0: } sl@0: if (aAllowedOutputMask & EVideoAllowHdmiHdcpRequired) sl@0: { sl@0: iSurfaceMask |= surfaceHints::EAllowDigitalProtectionRequired; sl@0: } sl@0: } sl@0: sl@0: if((!iSurfaceId.IsNull())) sl@0: { sl@0: err = AddHints(); sl@0: if(err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmavsoSetAllowedOutputL -- leaving err = %d"), this, err); sl@0: User::Leave(err); sl@0: } sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmavsoSetAllowedOutputL --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetPostProcessTypesL(TUint32 /*aCombination*/) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPostProcessTypesL ++"), this); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPostProcessTypesL --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetInputCropOptionsL(const TRect& /*aRect*/) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputCropOptionsL ++"), this); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetInputCropOptionsL --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetYuvToRgbOptionsL( const TYuvToRgbOptions& /*aOptions*/, const TYuvFormat& /*aYuvFormat*/, TRgbFormat /*aRgbFormat*/) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetYuvToRgbOptionsL ++"), this); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetYuvToRgbOptionsL --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetYuvToRgbOptionsL(const TYuvToRgbOptions& /*aOptions*/) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetYuvToRgbOptionsL ++"), this); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetYuvToRgbOptionsL --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetRotateOptionsL(TRotationType ) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetRotateOptionsL ++"), this); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetRotateOptionsL --")); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetScaleOptionsL(const TSize& /*aTargetSize*/, TBool /*aAntiAliasFiltering*/) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetScaleOptionsL ++"), this); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetScaleOptionsL --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetOutputCropOptionsL(const TRect& /*aRect*/) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetOutputCropOptionsL ++"), this); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetOutputCropOptionsL --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetPostProcSpecificOptionsL(const TDesC8& ) sl@0: { sl@0: //ignore sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::CommitL() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CommitL ++"), this); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CommitL --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::Revert() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Revert ++"), this); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Revert --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::StartDirectScreenAccessL( const TRect& /*aVideoRect*/, CFbsScreenDevice& /*aScreenDevice*/, const TRegion& /*aClipRegion*/) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:StartDSA ++"), this); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:StartDSA --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::AbortDirectScreenAccess() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AbortDSA ++"), this); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AbortDSA --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetScreenClipRegion(const TRegion& /*aRegion*/) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetScreenClipRegion ++"), this); sl@0: sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetScreenClipRegion --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetPauseOnClipFail(TBool ) sl@0: { sl@0: //ignore. Post Processor will always behave as aPause==False. sl@0: } sl@0: sl@0: TBool CNGAPostProcHwDevice::IsPlaying() sl@0: { sl@0: if( iPPState == EPlaying) sl@0: { sl@0: return ETrue; sl@0: } sl@0: else sl@0: { sl@0: return EFalse; sl@0: } sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::Redraw() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw ++"), this); sl@0: TInt err = KErrNone; sl@0: if(iRedrawSurfaceInUse && !iRedrawDone) sl@0: { sl@0: err = AddHints(); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw -- failed to AddHints %d"), sl@0: this, err); sl@0: iProxy->MdvppFatalError(this, err); sl@0: return; sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw registering the temp surface"), this); sl@0: err = RegisterSurface(iSurfaceId); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw -- failed to Register Surface %d"), sl@0: this, err); sl@0: iSurfaceHandler->DestroySurface(iSurfaceId); sl@0: iSurfaceId = TSurfaceId::CreateNullId(); sl@0: iProxy->MdvppFatalError(this, err); sl@0: return; sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw registering the temp surface done"), this); sl@0: err = iSessionManager->PostPicture(iSurfaceId, 0, EFalse); sl@0: if (err != KErrNone) sl@0: { sl@0: iProxy->MdvppFatalError(this, err); sl@0: return; sl@0: } sl@0: PublishSurfaceCreated(); sl@0: iRedrawDone = ETrue; sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Redraw --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::Start() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Start ++"), this); sl@0: iPPState = EPlaying; sl@0: sl@0: //TBC: when buffers given to post proc even before start. sl@0: //Even the buffers must be available to PostProc but not displayed. sl@0: //This will happen only when neighbouring decodeHwDevice decodes earlier than Start() sl@0: //call. Need to check if MDF guidelines allow this. sl@0: AttemptToPost(); sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Start --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::Stop() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Stop ++"), this); sl@0: iPPState = EStopped; sl@0: if (iSessionManager) sl@0: { sl@0: iSessionManager->CancelNotifiers(); sl@0: } sl@0: if (iPostingTimer) sl@0: { sl@0: iPostingTimer->Cancel(); sl@0: } sl@0: ReleaseProcessQ(); sl@0: ReleaseInputQ(); sl@0: sl@0: //Stop must keep on displaying the last frame. Blank Screen must not be visible sl@0: //to client. No Unregistering of surface should happen here. sl@0: //This Req is not necessary anymore. Only applicable to Pause. sl@0: sl@0: RDebug::Printf("------ Statistics of Post Processor ------"); sl@0: RDebug::Printf(" Pictures Received : %d", iPictureCounters.iTotalPictures); sl@0: RDebug::Printf(" Pictures Displayed: %d", iPictureCounters.iPicturesDisplayed); sl@0: RDebug::Printf(" Pictures Skipped : %d", iPictureCounters.iPicturesSkipped); sl@0: RDebug::Printf("------------------------------------------"); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Stop --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::Pause() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Pause ++"), this); sl@0: iPPState = EPaused; sl@0: iPostingTimer->Cancel(); sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Pause --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::Resume() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Resume ++"), this); sl@0: iPPState = EPlaying; sl@0: AttemptToPost(); sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Resume --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPosition ++"), this); sl@0: sl@0: if (iPPState == EInitializing) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPosition FAILED: Unexpected state"), this); sl@0: return; sl@0: } sl@0: if (iPPState == EPaused) sl@0: { sl@0: iFirstPictureUpdated = EFalse; sl@0: } sl@0: iCurrentPlaybackPosition = aPlaybackPosition; sl@0: sl@0: ReleaseInputQ(); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetPosition --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::FreezePicture(const TTimeIntervalMicroSeconds& ) sl@0: { sl@0: //TODO: sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::ReleaseFreeze(const TTimeIntervalMicroSeconds& ) sl@0: { sl@0: //TODO: sl@0: } sl@0: sl@0: TTimeIntervalMicroSeconds sl@0: CNGAPostProcHwDevice::PlaybackPosition() sl@0: { sl@0: if (iPPState == EInitializing) sl@0: { sl@0: return TTimeIntervalMicroSeconds(0); sl@0: } sl@0: sl@0: return iCurrentPlaybackPosition; sl@0: } sl@0: sl@0: TUint CNGAPostProcHwDevice::PictureBufferBytes() sl@0: { //TODO sl@0: return 0; sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::GetPictureCounters( CMMFDevVideoPlay::TPictureCounters& aCounters) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetPictureCounters ++"), this); sl@0: sl@0: if (iPPState == EInitializing) sl@0: return; sl@0: aCounters = iPictureCounters; sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetPictureCounters --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetComplexityLevel(TUint ) sl@0: { sl@0: //not required sl@0: } sl@0: sl@0: TUint CNGAPostProcHwDevice::NumComplexityLevels() sl@0: { sl@0: //not required sl@0: return 1; sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::GetComplexityLevelInfo(TUint , CMMFDevVideoPlay::TComplexityLevelInfo& ) sl@0: { sl@0: //not required sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::ReturnPicture(TVideoPicture* ) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReturnPicture +-"), this); sl@0: //not required for direct rendering sl@0: } sl@0: sl@0: TBool CNGAPostProcHwDevice::GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& /*aFormat*/) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL %d %d ++"), this, iVBMEnabled, iProcessQ.Count()); sl@0: TVideoPicture* pic = NULL; sl@0: TInt err = KErrNone; sl@0: TBool frameAvailable =EFalse; sl@0: tWndParam inputCropWindow; sl@0: tWndParam outputCropWindow; sl@0: tBaseVideoFrame inputFrame; sl@0: inputFrame.lum = NULL; sl@0: sl@0: if(aPictureData.iDataFormat == ERgbFbsBitmap) sl@0: { sl@0: if(iProcessQ.Count()) sl@0: { sl@0: pic = iProcessQ[0]; //frame already submitted for display sl@0: } sl@0: else if(iInputQ.Count()) sl@0: { sl@0: pic = iInputQ[0]; //frame yet to be displayed sl@0: } sl@0: if(pic) sl@0: { sl@0: if (iVBMEnabled) sl@0: { sl@0: inputFrame.lum = (TUint8*)pic->iData.iRawData->Ptr(); sl@0: } sl@0: else sl@0: { sl@0: if (iInputDecoderDevice) sl@0: { sl@0: MMmfVideoFetchFrame* VFHandler = NULL; sl@0: VFHandler = (MMmfVideoFetchFrame*)iInputDecoderDevice->CustomInterface(KUidMMFVideoFetchFrame); sl@0: if (VFHandler) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL() fetch frame"), this); sl@0: inputFrame.lum = (TUint8*)VFHandler->MmvffGetFrame(GetID(pic)); sl@0: } sl@0: else sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL() decoder yet to implement MMmfVideoFetchFrame CI"), this); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: if(inputFrame.lum) sl@0: { sl@0: inputFrame.cb = inputFrame.lum + iPicSize.iWidth * iPicSize.iHeight; sl@0: sl@0: if( ((iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma1) || sl@0: (iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma2) || sl@0: (iVideoFormat.iYuvFormat.iPattern == EYuv420Chroma3) )) sl@0: { sl@0: inputFrame.cr = inputFrame.lum + (iPicSize.iWidth * iPicSize.iHeight*5)/4; sl@0: } sl@0: else sl@0: { sl@0: inputFrame.cr = inputFrame.lum + (iPicSize.iWidth * iPicSize.iHeight*3)/2; sl@0: } sl@0: sl@0: inputFrame.width = (unsigned short)iPicSize.iWidth; sl@0: inputFrame.height = (unsigned short)iPicSize.iHeight; sl@0: sl@0: outputCropWindow.wndHeight = iPicSize.iHeight; sl@0: outputCropWindow.wndWidth = iPicSize.iWidth; sl@0: outputCropWindow.xOffset = 0; sl@0: outputCropWindow.yOffset = 0; sl@0: sl@0: inputCropWindow.wndHeight = iPicSize.iHeight; sl@0: inputCropWindow.wndWidth = iPicSize.iWidth; sl@0: inputCropWindow.xOffset = 0; sl@0: inputCropWindow.yOffset = 0; sl@0: sl@0: RFbsSession fbs; sl@0: User::LeaveIfError(fbs.Connect()); sl@0: CFbsBitmap* iOutBitmap = aPictureData.iRgbBitmap; sl@0: TInt status = iOutBitmap->Resize(iPicSize); sl@0: if (status == KErrNone) sl@0: { sl@0: // Lock the heap to prevent the FBS server from invalidating the address sl@0: iOutBitmap->LockHeap(); sl@0: TUint8* dataAddress = (TUint8*)iOutBitmap->DataAddress(); sl@0: err = ColorConvert(&inputFrame, dataAddress, &inputCropWindow, &outputCropWindow); sl@0: iOutBitmap->UnlockHeap(); sl@0: frameAvailable = ETrue; sl@0: } sl@0: fbs.Disconnect(); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: err = KErrNotSupported; sl@0: } sl@0: if(err != KErrNone) sl@0: { sl@0: User::Leave(err); sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:GetSnapshotL --"), this); sl@0: return(frameAvailable); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::InputEnd() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:InputEnd ++"), this); sl@0: sl@0: if (iPPState!=EPlaying && iPPState!=EPaused) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:InputEnd FAILED: Unexpected state"), this); sl@0: return; sl@0: } sl@0: iIsInputEnded = ETrue; sl@0: sl@0: if( (iProcessQ.Count() <= 1) && (iInputQ.Count() == 0)) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:InputEnd() Stream end"), this); sl@0: iProxy->MdvppStreamEnd(); sl@0: } sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:InputEnd --"), this); sl@0: } sl@0: sl@0: TAny* CNGAPostProcHwDevice::CustomInterface(TUid aInterface) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CustomInterface UID = %d ++"), this, aInterface.iUid); sl@0: sl@0: if (aInterface == KUidMmfVideoBufferManagement) sl@0: { sl@0: return (MMmfVideoBufferManagement *)this; sl@0: } sl@0: if (aInterface == KUidMMFVideoSurfaceSupport) sl@0: { sl@0: return (MMMFVideoSurfaceSupport *)this; sl@0: } sl@0: if (aInterface == KUidMMFVideoSurfaceHandleControl) sl@0: { sl@0: return (MMmfVideoSurfaceHandleControl *)this; sl@0: } sl@0: if (aInterface == KUidMmfVideoPlayRateControl) sl@0: { sl@0: return (MMmfVideoPlayRateControl *)this; sl@0: } sl@0: if (aInterface == KMmfVideoAdvancedSecureOutputUid) sl@0: { sl@0: return (MMmfAdvancedVideoSecureOutput *)this; sl@0: } sl@0: if (aInterface == KUidMmfVideoResourceManagement) sl@0: { sl@0: return (MMmfVideoResourceObserver *)this; sl@0: } sl@0: if (aInterface == KUidMmfPostInitializeRequest) sl@0: { sl@0: return (MMmfPostInitializeRequest *)this; sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CustomInterface --"), this); sl@0: return NULL; sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::BufferAvailable(TInt aBufId, TInt aStatus) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CNGAPostProcHwDevice::BufferAvailable aStatus = %d aBufId = %d++"), this, aStatus, aBufId); sl@0: TVideoPicture* pic = NULL; sl@0: if((aStatus != KErrNone) && (aStatus != KErrOverflow) && (aStatus != KErrNotVisible)) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:BufferAvailable FAILED: aStatus = %d"), this, aStatus); sl@0: iProxy->MdvppFatalError(this, aStatus); sl@0: } sl@0: sl@0: if(aStatus == KErrOverflow) sl@0: { sl@0: iOverflowPictureCounter++; sl@0: PicturesSkipped(); sl@0: } sl@0: sl@0: if (iVBMEnabled) sl@0: { sl@0: for(TInt i=0; i < iProcessQ.Count(); i++) sl@0: { sl@0: if(iVBMBufferReferenceQ[aBufId] == iProcessQ[i]) sl@0: { sl@0: pic = iProcessQ[i]; sl@0: iProcessQ.Remove(i); sl@0: ReturnPicToDecoder(pic); sl@0: if (iIsColorConversionNeeded) sl@0: { sl@0: AddPictureToColorConversionQ(pic); sl@0: } sl@0: else sl@0: { sl@0: AddPictureToVBMQ(pic); sl@0: } sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: for(TInt i=0; i < iProcessQ.Count(); i++) sl@0: { sl@0: TInt bufId; sl@0: if (iUsingExternalSurface) sl@0: { sl@0: bufId = GetExternalBufferID(iProcessQ[i]); sl@0: } sl@0: else sl@0: { sl@0: bufId = GetID(iProcessQ[i]); sl@0: } sl@0: sl@0: if (aBufId == bufId) sl@0: { sl@0: pic = iProcessQ[i]; sl@0: iProcessQ.Remove(i); sl@0: ReturnPicToDecoder(pic); sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: sl@0: if(aStatus == KErrNone) sl@0: { sl@0: if (!iKeyFrameMode && iPlayRate>KDefPlayRate) sl@0: { sl@0: if (iSkippedFramesCountingBuffer[iCurrentPosInFramesCountingBuffer]==1) sl@0: { sl@0: iSkippedFramesCountingBuffer[iCurrentPosInFramesCountingBuffer] = 0; sl@0: iSkippedFramesInLast64Frames--; sl@0: } sl@0: iCurrentPosInFramesCountingBuffer = ++iCurrentPosInFramesCountingBuffer%64; sl@0: } sl@0: iPictureCounters.iPicturesDisplayed++; sl@0: if (iStepFrameCount != 0) sl@0: { sl@0: iStepFrameCount > 0 ? iStepFrameCount-- : iStepFrameCount++; sl@0: if (iStepFrameCount==0 && iFPObserver) sl@0: { sl@0: iFPObserver->MmvproStepFrameComplete(pic->iTimestamp); sl@0: } sl@0: } sl@0: } sl@0: sl@0: if(iPPState == EPlaying) sl@0: { sl@0: AttemptToPost(); sl@0: } sl@0: sl@0: if( iIsInputEnded && (iProcessQ.Count() <= 1) && (iInputQ.Count() == 0)) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:BufferAvailable() Stream end"), this); sl@0: iProxy->MdvppStreamEnd(); sl@0: } sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:CNGAPostProcHwDevice::BufferAvailable --"), this); sl@0: } sl@0: sl@0: //=== MMmfVideoBufferManagement === sl@0: void CNGAPostProcHwDevice::MmvbmSetObserver(MMmfVideoBufferManagementObserver* aObserver) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetObserver() ++"), this); sl@0: sl@0: if (iPPState != EInitializing) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetObserver FAILED: Unexpected state"), this); sl@0: iProxy->MdvppFatalError(this, KErrNotReady); sl@0: } sl@0: sl@0: iVBMObserver = aObserver; sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetObserver() --"), this); sl@0: } sl@0: sl@0: sl@0: void CNGAPostProcHwDevice::MmvbmEnable(TBool aEnable) sl@0: { sl@0: if (iPPState != EInitializing) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmEnable FAILED: Unexpected state"), this); sl@0: iProxy->MdvppFatalError(this, KErrNotReady); sl@0: } sl@0: sl@0: iVBMEnabled = aEnable; sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::MmvbmSetBufferOptionsL(const TBufferOptions& aOptions) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetBufferOptionsL ++"), this); sl@0: sl@0: if (iPPState != EInitializing) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetBufferOptionsL FAILED: Unexpected state"), this); sl@0: User::Leave(KErrNotReady); sl@0: } sl@0: sl@0: // why limiting the number of buffers? any particular reason for this? sl@0: //if (aOptions.iNumInputBuffers > KMaxVBMBuffers || aOptions.iNumInputBuffers <= 1) //at least two buffers sl@0: if (aOptions.iNumInputBuffers <= 1) //at least two buffers sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetBufferOptionsL FAILED: Input buffer count limit"), this); sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: if (aOptions.iNumInputBuffers == 0 sl@0: || aOptions.iBufferSize.iWidth <= KMinVBMInputWidth sl@0: || aOptions.iBufferSize.iHeight <= KMinVBMInputHeight sl@0: || aOptions.iBufferSize.iWidth > KMaxVBMInputWidth sl@0: || aOptions.iBufferSize.iHeight > KMaxVBMInputHeight) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetBufferOptionsL FAILED: Unexpected buffer size"), this); sl@0: User::Leave(KErrArgument); sl@0: } sl@0: sl@0: iVBMBufferOptions.iNumInputBuffers = aOptions.iNumInputBuffers; sl@0: iVBMBufferOptions.iBufferSize = aOptions.iBufferSize; sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmSetBufferOptionsL --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::MmvbmGetBufferOptions(TBufferOptions& aOptions) sl@0: { sl@0: if (iPPState == EInitializing) sl@0: { sl@0: aOptions = iVBMBufferOptions; sl@0: } sl@0: else sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferOptions FAILED: Unexpected state"), this); sl@0: iProxy->MdvppFatalError(this, KErrNotReady); sl@0: } sl@0: } sl@0: sl@0: TVideoPicture* CNGAPostProcHwDevice::MmvbmGetBufferL(const TSize& aSize) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() ++"), this); sl@0: sl@0: TInt err = KErrNone; sl@0: TVideoPicture* lPic = NULL; sl@0: sl@0: if (iPPState == EInitializing) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() FAILED: Unexpected state"), this); sl@0: User::Leave(KErrNotReady); sl@0: } sl@0: sl@0: if (aSize.iWidth < KMinVBMInputWidth sl@0: || aSize.iHeight < KMinVBMInputHeight sl@0: || aSize.iWidth > iVBMBufferOptions.iBufferSize.iWidth sl@0: || aSize.iHeight > iVBMBufferOptions.iBufferSize.iHeight) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() FAILED: Unexpected buffer size w=%d h=%d "), this,aSize.iWidth,aSize.iHeight ); sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: if(iVBMBufferReferenceQ.Count() == 0) sl@0: { sl@0: iPicSize = aSize; sl@0: err = SetupSurface(); sl@0: if(err) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() Surface Setup Failed %d"), this, err); sl@0: User::Leave(err); sl@0: } sl@0: } sl@0: sl@0: if(!iVBMBufferQ.Count()) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() WARNING: Queue buffer count zero"), this); sl@0: return NULL; sl@0: } sl@0: sl@0: lPic = iVBMBufferQ[0]; sl@0: iVBMBufferQ.Remove(0); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmGetBufferL() -- %d"), this, lPic); sl@0: return lPic; sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::MmvbmReleaseBuffer(TVideoPicture* aBuffer) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmReleaseBuffer() ++"), this); sl@0: sl@0: if(!aBuffer) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmReleaseBuffer() FAILED: Invalid buffer ptr"), this); sl@0: iProxy->MdvppFatalError(this, KErrArgument); sl@0: } sl@0: sl@0: TInt err = iVBMBufferQ.Append(aBuffer); sl@0: if (err) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmReleaseBuffer() FAILED: Failed to append"), this); sl@0: iProxy->MdvppFatalError(this, err); sl@0: } sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvbmReleaseBuffer() --"), this); sl@0: } sl@0: sl@0: //=== MMMFVideoSurfaceSupport === sl@0: sl@0: void CNGAPostProcHwDevice::MmvssUseSurfaces() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssUseSurfaces() ++"), this); sl@0: // do nothing sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssUseSurfaces() --"), this); sl@0: } sl@0: sl@0: TInt CNGAPostProcHwDevice::MmvshcCreateSurface(const RSurfaceManager::TSurfaceCreationAttributes& aAttributes, TInt aHandle, TSurfaceId& aSurfaceId) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcCreateSurface() ++"), this); sl@0: TInt err(KErrNone); sl@0: sl@0: if(!iSurfaceId.IsNull()) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssCreateSurface Cleaning Surface"), this); sl@0: sl@0: if (iVideoSurfaceObserver && iSurfaceCreatedEventPublished) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcCreateSurface - Telling client to remove old surface"), this); sl@0: iVideoSurfaceObserver->MmvsoRemoveSurface(); sl@0: iSurfaceCreatedEventPublished = EFalse; sl@0: } sl@0: else sl@0: { sl@0: // We never told the client about the surface, so we must destroy it ourselves sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface - Destroying old surface"), this); sl@0: TInt numScreens = iWsSession.NumberOfScreens(); sl@0: for(TInt i=0;i < numScreens;i++) sl@0: { sl@0: iWsSession.UnregisterSurface(i, iSurfaceId); sl@0: } sl@0: iWsSession.Flush(); sl@0: iSurfaceHandler->DestroySurface(iSurfaceId); sl@0: } sl@0: //remove any handle to chunk. not needed perhaps sl@0: iChunk.Close(); sl@0: sl@0: } sl@0: sl@0: // Create the surface handler if it doesn't exist. sl@0: if (!iSurfaceHandler) sl@0: { sl@0: TRAP(err, iSurfaceHandler = CNGAPostProcSurfaceHandler::NewL()); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssCreateSurface -- failed to create SurfaceHandler."), this); sl@0: return err; sl@0: } sl@0: } sl@0: sl@0: iChunk.SetHandle(aHandle); sl@0: err = iSurfaceHandler->CreateSurface(aAttributes, aSurfaceId, iChunk); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssCreateSurface -- failed to create surface %d"), this, err); sl@0: return err; sl@0: } sl@0: iSurfaceId = aSurfaceId; sl@0: iIsExternalChunk = ETrue; sl@0: sl@0: err = RegisterSurface(iSurfaceId); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssCreateSurface -- failed RegisterSurface %d"), this, err); sl@0: iSurfaceHandler->DestroySurface(iSurfaceId); sl@0: iSurfaceId = TSurfaceId::CreateNullId(); sl@0: return err; sl@0: } sl@0: sl@0: err = iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssCreateSurface -- failed to get Surface info %d"), this, err); sl@0: return err; sl@0: } sl@0: sl@0: if(iAttributes().iPixelFormat == EUidPixelFormatYUV_422Interleaved) sl@0: { sl@0: iVideoFrameBufSize = iInfo().iSize.iWidth * iInfo().iSize.iHeight * 2; sl@0: } sl@0: else sl@0: {//EStUidPixelFormatYUV_420MB sl@0: // EUidPixelFormatYUV_420Planar sl@0: iVideoFrameBufSize = iInfo().iSize.iWidth * iInfo().iSize.iHeight * 3/2; sl@0: } sl@0: sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcCreateSurface err=%d"), this, err); sl@0: return err; sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::MmvssSetObserver(MMMFVideoSurfaceObserver& aObserver) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSetObserver() ++"), this); sl@0: iVideoSurfaceObserver = &aObserver; sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSetObserver() --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::MmvssGetSurfaceParametersL(TSurfaceId& aSurfaceId, sl@0: TRect& aCropRect, TVideoAspectRatio& aPixelAspectRatio) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() ++"), this); sl@0: sl@0: iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo); sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() \ sl@0: surfaceWidth = %d surfaceHeight = %d SurfaceId = 0x%x --"), sl@0: this, iInfo().iSize.iWidth, iInfo().iSize.iHeight, iSurfaceId); sl@0: aSurfaceId = iSurfaceId; sl@0: aCropRect = TRect(0, 0, iInfo().iSize.iWidth, iInfo().iSize.iHeight); sl@0: if((iPicSize.iWidth > 0) && (iPicSize.iHeight > 0)) sl@0: { sl@0: aCropRect.Intersection( iPicSize); sl@0: } sl@0: aPixelAspectRatio = TVideoAspectRatio(iAspectRatioNum,iAspectRatioDenom); sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() \ sl@0: cropRectWidth = %d cropRectHeight = %d"), this, aCropRect.Width(), aCropRect.Height()); sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() \ sl@0: PAR Num = %d PAR Denom = %d"), this, aPixelAspectRatio.iNumerator, aPixelAspectRatio.iDenominator); sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssGetSurfaceParametersL() --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::MmvssSurfaceRemovedL(const TSurfaceId& aSurfaceId) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL()++"), this); sl@0: if(!aSurfaceId.IsNull()) sl@0: { sl@0: if(iSurfaceId == aSurfaceId) sl@0: {//closing down top surface....current surface. sl@0: if(iSessionManager) sl@0: { sl@0: iSessionManager->CancelNotifiers(); sl@0: } sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL(): UnregisterSurface ID = 0x%x"), this, aSurfaceId ); sl@0: TInt numScreens = iWsSession.NumberOfScreens(); sl@0: for(TInt i=0;i < numScreens;i++) sl@0: { sl@0: iWsSession.UnregisterSurface(i, aSurfaceId); sl@0: } sl@0: iWsSession.Flush(); sl@0: iSurfaceHandler->DestroySurface(aSurfaceId); sl@0: if(iSurfaceId == aSurfaceId) sl@0: { sl@0: iSurfaceCreatedEventPublished = EFalse; sl@0: iSurfaceId = TSurfaceId::CreateNullId(); sl@0: if(!iIsExternalChunk) sl@0: { sl@0: iChunk.Close(); sl@0: } sl@0: } sl@0: } sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvssSurfaceRemovedL() --"), this); sl@0: } sl@0: sl@0: // === MMmfVideoPropertiesObserver === sl@0: sl@0: void CNGAPostProcHwDevice::MmvpoUpdateVideoProperties(const TYuvFormat& aYuvFormat, const TSize& aPictureSize) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties ++"), this); sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties PAR \ sl@0: iAspectRatioNum = %d, iAspectRatioDenom = %d"), this, sl@0: aYuvFormat.iAspectRatioNum,aYuvFormat.iAspectRatioDenom); sl@0: iPicSize = aPictureSize; sl@0: iAspectRatioNum = aYuvFormat.iAspectRatioNum; sl@0: iAspectRatioDenom = aYuvFormat.iAspectRatioDenom; sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties Picture Size \ sl@0: iWidth = %d, iHeight = %d, iSurfaceCreatedEventPublished = %d"), sl@0: this, iPicSize.iWidth,iPicSize.iHeight, iSurfaceCreatedEventPublished?1:0); sl@0: sl@0: if(iVPObserver) sl@0: { sl@0: iVPObserver->MmvpoUpdateVideoProperties(aYuvFormat, aPictureSize); sl@0: } sl@0: if(iVideoSurfaceObserver && iSurfaceCreatedEventPublished) sl@0: { sl@0: iVideoSurfaceObserver->MmvsoSurfaceParametersChanged(); sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvpoUpdateVideoProperties --"), this); sl@0: } sl@0: sl@0: // === MMmfVideoResourceObserver === sl@0: sl@0: void CNGAPostProcHwDevice::MmvroResourcesLost(TUid ) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost ++"), this); sl@0: if(!iResourceLost) sl@0: { sl@0: iResourceLost = ETrue; sl@0: iRedrawDone = EFalse; sl@0: Pause(); sl@0: ReleaseInputQ(); sl@0: iSessionManager->CancelNotifiers(); sl@0: ReleaseProcessQ(); sl@0: if(iVideoSurfaceObserver && iSurfaceCreatedEventPublished) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost - Telling client to remove surface"), this); sl@0: iVideoSurfaceObserver->MmvsoRemoveSurface(); sl@0: iSurfaceCreatedEventPublished = EFalse; sl@0: } sl@0: } sl@0: else if(iResourceLost && iRedrawDone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost ResourceLost happening \ sl@0: while Postprocessor is already in ResourceLoss state"), sl@0: this); sl@0: iProxy->MdvppFatalError(this, KErrHardwareNotAvailable); sl@0: return; sl@0: } sl@0: else sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost Ignoring the \ sl@0: duplicate ResourceLoss call"), sl@0: this); sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvroResourcesLost --"), this); sl@0: } sl@0: sl@0: // === MMmfVideoPropertiesNotifier === sl@0: sl@0: void CNGAPostProcHwDevice::MmvpnSetObserver(MMmfVideoPropertiesObserver* aObserver) sl@0: { sl@0: PP_DEBUG(_L("ppHwDev[%x]::MmvpnSetObserver ++"), this); sl@0: iVPObserver = aObserver; sl@0: PP_DEBUG(_L("ppHwDev[%x]::MmvpnSetObserver --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::MmvroResourcesRestored(TUid ) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvroResourcesRestored ++"), this); sl@0: iFirstPictureUpdated = EFalse; sl@0: iResourceLost = EFalse; sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvroResourcesRestored state=%d --"), sl@0: this, iPPState); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::MmvshcSetSurfaceHandle(const TSurfaceId &aSurfaceID) sl@0: { sl@0: sl@0: SetupExternalSurface(aSurfaceID); sl@0: sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::MmvshcRedrawBufferToSurface(TPtrC8& aRedrawBuffer) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface ++"), this); sl@0: sl@0: TUint8* lPtr; sl@0: TInt offset; sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface -- Creating %d x %d surface"), this, iPicSize.iWidth, iPicSize.iHeight); sl@0: sl@0: TInt err = KErrNone; sl@0: SetSurfaceAttributes(iPicSize, 1); sl@0: sl@0: err = iSurfaceHandler->CreateSurface(iAttributes, iSurfaceId); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to create Surface %d"), sl@0: this, err); sl@0: iProxy->MdvppFatalError(this, err); sl@0: return; sl@0: } sl@0: sl@0: err = iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to get Surface info %d"), sl@0: this, err); sl@0: iSurfaceHandler->DestroySurface(iSurfaceId); sl@0: iSurfaceId = TSurfaceId::CreateNullId(); sl@0: iProxy->MdvppFatalError(this, err); sl@0: return; sl@0: } sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface() \ sl@0: surfaceWidth = %d surfaceHeight = %d surfaceStride = %d"), this, iInfo().iSize.iWidth, iInfo().iSize.iHeight, iInfo().iStride); sl@0: sl@0: TInt redrawBufferSize = aRedrawBuffer.Size(); sl@0: TInt surfaceSize = iInfo().iStride * iInfo().iSize.iHeight; sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface RedrawBuffer size= %d Surface size = %d"), this, redrawBufferSize, surfaceSize); sl@0: sl@0: // Check whether redraw buffer will fit onto the surface. sl@0: // If this check fails then we won't raise a fatal error - We just won't create the redraw surface sl@0: if (redrawBufferSize > surfaceSize) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface Redraw buffer size larger than surface size"), this); sl@0: iSurfaceHandler->DestroySurface(iSurfaceId); sl@0: iSurfaceId = TSurfaceId::CreateNullId(); sl@0: return; sl@0: } sl@0: sl@0: err = iSurfaceHandler->MapSurface(iSurfaceId, iChunk); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:MmvshcRedrawBufferToSurface -- failed to map Surface %d"), sl@0: this, err); sl@0: iSurfaceHandler->DestroySurface(iSurfaceId); sl@0: iSurfaceId = TSurfaceId::CreateNullId(); sl@0: iProxy->MdvppFatalError(this, err); sl@0: return; sl@0: } sl@0: iIsExternalChunk = EFalse; sl@0: if((err = iSurfaceHandler->GetBufferOffset(iSurfaceId, 0, offset)) != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface offset query failed %d"), this, err); sl@0: iSurfaceHandler->DestroySurface(iSurfaceId); sl@0: iSurfaceId = TSurfaceId::CreateNullId(); sl@0: iChunk.Close(); sl@0: iProxy->MdvppFatalError(this, err); sl@0: return; sl@0: } sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface offset = %d"), this, offset); sl@0: sl@0: lPtr = reinterpret_cast(iChunk.Base() + offset); sl@0: memcpy((TAny *)lPtr, (TAny *)aRedrawBuffer.Ptr(), redrawBufferSize); sl@0: sl@0: iRedrawSurfaceInUse = ETrue; sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface(): New surface = 0x%x"), this, iSurfaceId); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::MmvshcRedrawBufferToSurface error = %d --"), this, err); sl@0: } sl@0: sl@0: TInt CNGAPostProcHwDevice::SetupExternalSurface(const TSurfaceId &aSurfaceID) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface(): aSurfaceID = 0x%x"), this, aSurfaceID ); sl@0: sl@0: TInt err = KErrNone; sl@0: sl@0: if(!iSurfaceId.IsNull()) sl@0: { sl@0: if (iVideoSurfaceObserver && iSurfaceCreatedEventPublished) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface - Telling client to remove old surface"), this); sl@0: iVideoSurfaceObserver->MmvsoRemoveSurface(); sl@0: iSurfaceCreatedEventPublished = EFalse; sl@0: } sl@0: else sl@0: { sl@0: // We never told the client about the surface, so we must destroy it ourselves sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface - Destroying old surface"), this); sl@0: TInt numScreens = iWsSession.NumberOfScreens(); sl@0: for(TInt i=0;i < numScreens;i++) sl@0: { sl@0: iWsSession.UnregisterSurface(i, iSurfaceId); sl@0: } sl@0: iWsSession.Flush(); sl@0: iSurfaceHandler->DestroySurface(iSurfaceId); sl@0: } sl@0: sl@0: iChunk.Close(); sl@0: } sl@0: sl@0: iSurfaceId = aSurfaceID; sl@0: iUsingExternalSurface = ETrue; sl@0: iRedrawSurfaceInUse = EFalse; sl@0: sl@0: // Create the surface handler if it doesn't exist. sl@0: if (!iSurfaceHandler) sl@0: { sl@0: TRAP(err, iSurfaceHandler = CNGAPostProcSurfaceHandler::NewL()); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface -- failed to create SurfaceHandler."), this); sl@0: return err; sl@0: } sl@0: } sl@0: sl@0: err = iSurfaceHandler->OpenSurface(iSurfaceId); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface -- failed OpenSurface %d"), sl@0: this, err); sl@0: return err; sl@0: } sl@0: err = AddHints(); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface -- failed to AddHints %d"), sl@0: this, err); sl@0: return err; sl@0: } sl@0: err = RegisterSurface(iSurfaceId); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface -- failed RegisterSurface %d"), sl@0: this, err); sl@0: iSurfaceHandler->DestroySurface(iSurfaceId); sl@0: iSurfaceId = TSurfaceId::CreateNullId(); sl@0: return err; sl@0: } sl@0: sl@0: err = iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface -- failed to get Surface info %d"), sl@0: this, err); sl@0: return err; sl@0: } sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetupExternalSurface err=%d"), this, err); sl@0: return err; sl@0: } sl@0: sl@0: //=== Internal === sl@0: TVideoPicture* CNGAPostProcHwDevice::CreateBuffersL(TInt aBufId) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateBuffersL ++"), this); sl@0: sl@0: TVideoPicture* lVideoPicture = NULL; sl@0: TUint8* lPtr; sl@0: TPtr8* lTemp; sl@0: TInt offset; sl@0: sl@0: lVideoPicture = new (ELeave) TVideoPicture; sl@0: CleanupStack::PushL(lVideoPicture); sl@0: if(TInt err = iSurfaceHandler->GetBufferOffset(iSurfaceId, aBufId, offset) != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateBuffersL offset query failed %d"), this, err); sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateBuffersL offset = %d id =%d --"), this, offset, aBufId); sl@0: sl@0: lPtr = reinterpret_cast(iChunk.Base() + offset); sl@0: sl@0: lTemp = new (ELeave) TPtr8(lPtr, 0, (iVideoFrameBufSize )); sl@0: CleanupStack::PushL(lTemp); sl@0: sl@0: lVideoPicture->iData.iRawData = lTemp; sl@0: lVideoPicture->iHeader = NULL ; sl@0: lVideoPicture->iLayerBitRates = NULL ; sl@0: sl@0: CleanupStack::Pop(2); sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateVBMBuffersL --"), this); sl@0: return lVideoPicture; sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::CreateVBMBuffersL() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateVBMBuffersL ++"), this); sl@0: sl@0: TInt err = KErrNone; sl@0: TVideoPicture* pic = NULL; sl@0: iVBMBufferReferenceQ.Reset(); sl@0: iVBMBufferQ.Reset(); sl@0: iColorConversionQ.Reset(); sl@0: sl@0: for(TInt i = 0; i < iVBMBufferOptions.iNumInputBuffers; i++) sl@0: { sl@0: TRAP(err, pic = CreateBuffersL(i)); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create VBM buffer %d"), this, err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: // This will hold the references which will be used in destructor sl@0: User::LeaveIfError(iVBMBufferReferenceQ.Append(pic)); sl@0: User::LeaveIfError(iVBMBufferQ.Append(pic)); sl@0: } sl@0: if(iIsColorConversionNeeded) sl@0: { sl@0: for(TInt i = iVBMBufferOptions.iNumInputBuffers ; sl@0: i < (iVBMBufferOptions.iNumInputBuffers + KColorConversionBuffers ); i++) sl@0: { sl@0: TRAP(err, pic = CreateBuffersL(i)); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create VBM buffer %d"), this, err); sl@0: User::Leave(err); sl@0: } sl@0: sl@0: // This will hold the references which will be used in destructor sl@0: User::LeaveIfError(iVBMBufferReferenceQ.Append(pic)); sl@0: User::LeaveIfError(iColorConversionQ.Append(pic)); sl@0: } sl@0: } sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]::CreateVBMBuffersL --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::ReturnPicToDecoder(TVideoPicture* aPic) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReturnPicToDecoder ++"), this); sl@0: if (aPic == NULL) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputPicture FAILED: Invalid pic ptr."), this); sl@0: return; sl@0: } sl@0: sl@0: if (iInputDecoderDevice) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputPicture .. before return picture. 2"), this); sl@0: iInputDecoderDevice->ReturnPicture(aPic); sl@0: } sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReturnPicToDecoder --"), this); sl@0: } sl@0: sl@0: TInt CNGAPostProcHwDevice::AttemptToPost() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AttemptToPost ++ Q:%d"), this, iInputQ.Count()); sl@0: if (iPPState == EPaused) sl@0: { sl@0: return KErrNone; sl@0: } sl@0: sl@0: TInt err = KErrNotReady; sl@0: TInt count = iInputQ.Count(); sl@0: TBool bDone = EFalse; sl@0: TVideoPicture* pic = PeekQ(); sl@0: while(pic && !bDone) sl@0: { sl@0: if(!IsGceReady()) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AttemptToPost GCE not ready"), this ); sl@0: return err; //no need to catch this error sl@0: } sl@0: TInt64 delta = 0; sl@0: TTimeToPost timeToPost = (TTimeToPost)IsTimeToPost(pic, delta); sl@0: switch(timeToPost) sl@0: { sl@0: case EDelayIt: sl@0: { sl@0: iPostingTimer->Cancel(); sl@0: SetTimer(delta); sl@0: bDone = ETrue; sl@0: } sl@0: break; sl@0: case EPostIt: sl@0: { sl@0: RemoveFromQ(); // remove the pic that was returned by PeekQ sl@0: if(iIsColorConversionNeeded) sl@0: { sl@0: TVideoPicture* ccPic; sl@0: ccPic = DoColorConvert(pic); // output will be in ccPic sl@0: pic = ccPic; sl@0: } sl@0: sl@0: #ifdef _DUMP_YUV_FRAMES sl@0: captureYuv(pic); sl@0: #endif sl@0: TInt err = iSessionManager->PostPicture(iSurfaceId, GetID(pic), ETrue); sl@0: if(err == KErrNone) sl@0: { sl@0: iProcessQ.Append(pic); sl@0: iCurrentPlaybackPosition = pic->iTimestamp; sl@0: if(!iFirstPictureUpdated) sl@0: { sl@0: iFirstPictureUpdated = ETrue; sl@0: if(!iSurfaceCreatedEventPublished) sl@0: { sl@0: PublishSurfaceCreated(); sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ReleasePicture(pic); sl@0: } sl@0: sl@0: sl@0: } // end of postit sl@0: break; sl@0: case ESkipIt: sl@0: { sl@0: RemoveFromQ(); sl@0: ReleasePicture(pic); sl@0: PicturesSkipped(); sl@0: } sl@0: break; sl@0: } // end of switch sl@0: sl@0: // get the next picture sl@0: pic = PeekQ(); sl@0: } // end of while sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AttemptToPost --"), this); sl@0: return err; sl@0: } sl@0: sl@0: TInt CNGAPostProcHwDevice::IsTimeToPost(TVideoPicture* frame, TInt64& delta) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost ++"), this); sl@0: sl@0: if (!frame) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost FAILED: Invalid frame ptr."), this); sl@0: return KErrGeneral; sl@0: } sl@0: sl@0: TInt resp = EPostIt; sl@0: // Frame presentation time sl@0: TInt64 uPresTime = frame->iTimestamp.Int64(); sl@0: sl@0: // Check if this is an out of order frame in case of forward playback sl@0: if((iCurrentPlaybackPosition.Int64() > uPresTime) && (iPlayRate > 0)) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost : Out of order frame (forward playback) Tfm=%d"), this,(TInt)uPresTime); sl@0: resp = ESkipIt; //drop sl@0: } // Check if this is an out of order frame in case of backward playback sl@0: else if((iCurrentPlaybackPosition.Int64() < uPresTime) && (iPlayRate < 0)) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost : Out of order frame (backward playback) Tfm=%d"), this,(TInt)uPresTime); sl@0: resp = ESkipIt; //drop sl@0: } sl@0: else if (iClockSource) sl@0: { sl@0: // The time to sync with. sl@0: TInt64 uSyncTime = iClockSource->Time().Int64(); sl@0: sl@0: delta = uPresTime - uSyncTime; sl@0: if (( delta > KRenderAhead ) && (iPlayRate > 0)) // Delay condition not checked for sl@0: { // backward playback sl@0: resp = EDelayIt; //wait sl@0: } sl@0: else if ( (delta < (-KMaxRenderDelay) && (iPlayRate > 0)) sl@0: || ((delta > KMaxRenderDelay) && (iPlayRate < 0))) sl@0: { sl@0: resp = ESkipIt; //drop sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost .. Tfm=%d, Tcs=%d, delta=%d"), this, (TInt)uPresTime, (TInt)uSyncTime, (TInt)delta); sl@0: } sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:IsTimeToPost -- %d BufID = %d"), this, resp, GetID(frame)); sl@0: return resp; sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::ReleaseInputQ() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputQ ++ Q = %d"), this, iInputQ.Count()); sl@0: while (iInputQ.Count()>0) sl@0: { sl@0: ReleasePicture(iInputQ[0]); sl@0: iInputQ.Remove(0); sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputQ --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::ReleaseProcessQ() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseProcessQ ++ Q = %d"), this, iProcessQ.Count() ); sl@0: TVideoPicture* pic = NULL; sl@0: sl@0: while (iProcessQ.Count()>0) sl@0: { sl@0: pic = iProcessQ[0]; sl@0: iProcessQ.Remove(0); sl@0: ReturnPicToDecoder(pic); sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseProcessQ --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::ReleasePicture(TVideoPicture *pic) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleasePicture ++"), this); sl@0: if (pic == NULL) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputPicture FAILED: Invalid pic ptr."), this); sl@0: return; sl@0: } sl@0: sl@0: if (iInputDecoderDevice) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleaseInputPicture .. before return picture. 2"), this); sl@0: iInputDecoderDevice->ReturnPicture(pic); sl@0: } sl@0: if (iVBMEnabled) sl@0: { sl@0: iVBMBufferQ.Append(pic); sl@0: sl@0: if ( !iIsInputEnded && iPPState != EStopped ) sl@0: { sl@0: iVBMObserver->MmvbmoNewBuffers(); sl@0: } sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ReleasePicture --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::PublishSurfaceCreated() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PublishSurfaceCreated ++"), this); sl@0: if(iVideoSurfaceObserver) sl@0: { sl@0: iVideoSurfaceObserver->MmvsoSurfaceCreated(); sl@0: iSurfaceCreatedEventPublished = ETrue; sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PublishSurfaceCreated --"), this); sl@0: } sl@0: sl@0: TInt CNGAPostProcHwDevice::SetupSurface() sl@0: { sl@0: TInt err = KErrNone; sl@0: if(iVBMEnabled && iVBMObserver) sl@0: { sl@0: SetSurfaceAttributes(iVBMBufferOptions.iBufferSize, iVBMBufferOptions.iNumInputBuffers); sl@0: sl@0: err = iSurfaceHandler->CreateSurface(iAttributes, iSurfaceId); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create Surface %d"), this, err); sl@0: return err; sl@0: } sl@0: err = iSurfaceHandler->MapSurface(iSurfaceId, iChunk); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to map Surface %d"), this, err); sl@0: iSurfaceHandler->DestroySurface(iSurfaceId); sl@0: iSurfaceId = TSurfaceId::CreateNullId(); sl@0: return err; sl@0: } sl@0: err = iSurfaceHandler->SurfaceInfo(iSurfaceId, iInfo); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to get Surface info %d"), this, err); sl@0: iSurfaceHandler->DestroySurface(iSurfaceId); sl@0: iSurfaceId = TSurfaceId::CreateNullId(); sl@0: return err; sl@0: } sl@0: TRAP(err, CreateVBMBuffersL()); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create VBM buffer %d"), this, err); sl@0: iSurfaceHandler->DestroySurface(iSurfaceId); sl@0: iSurfaceId = TSurfaceId::CreateNullId(); sl@0: return err; sl@0: } sl@0: err = AddHints(); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to AddHints %d"), this, err); sl@0: return err; sl@0: } sl@0: err = RegisterSurface(iSurfaceId); sl@0: if (err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to RegisterSurface %d"), this, err); sl@0: iSurfaceHandler->DestroySurface(iSurfaceId); sl@0: iSurfaceId = TSurfaceId::CreateNullId(); sl@0: return err; sl@0: } sl@0: sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetSurfaceAttributes(const TSize& aSize, TInt aNumBuf) sl@0: { sl@0: iAttributes().iSize = aSize; // size of the video frame sl@0: iAttributes().iBuffers = aNumBuf; sl@0: sl@0: /* The stride needs to be calculated for the surface manager to know sl@0: how much memory to allocate */ sl@0: sl@0: if(iAttributes().iPixelFormat == EUidPixelFormatYUV_420Planar) sl@0: { sl@0: iAttributes().iStride = aSize.iWidth * 3/2; sl@0: iVideoFrameBufSize = aSize.iWidth * aSize.iHeight * 3/2; sl@0: } sl@0: else sl@0: { sl@0: iAttributes().iStride = aSize.iWidth * 2; sl@0: iVideoFrameBufSize = aSize.iWidth * aSize.iHeight * 2; sl@0: } sl@0: sl@0: if(iIsColorConversionNeeded) sl@0: { sl@0: iAttributes().iBuffers = aNumBuf + KColorConversionBuffers; sl@0: } sl@0: else sl@0: { sl@0: iAttributes().iBuffers = aNumBuf; sl@0: } sl@0: sl@0: iAttributes().iOffsetToFirstBuffer = 0; sl@0: #if defined __WINSCW__ sl@0: iAttributes().iAlignment = 4; sl@0: #else //on hw, its always better to have page aligned chunks sl@0: iAttributes().iAlignment = -1; sl@0: #endif sl@0: iAttributes().iContiguous = ETrue; sl@0: iAttributes().iHintCount = 0; sl@0: iAttributes().iMappable = ETrue; sl@0: } sl@0: sl@0: TInt CNGAPostProcHwDevice::GetID(TVideoPicture *aPicture) sl@0: { sl@0: if (iUsingExternalSurface) sl@0: { sl@0: return GetExternalBufferID(aPicture); sl@0: } sl@0: else sl@0: { sl@0: TUint8* aPtr = (TUint8*) aPicture->iData.iRawData->Ptr(); sl@0: return( (TInt) ((aPtr - iChunk.Base() - iAttributes().iOffsetToFirstBuffer) / sl@0: (iVideoFrameBufSize ))); sl@0: } sl@0: } sl@0: sl@0: TInt CNGAPostProcHwDevice::GetExternalBufferID(TVideoPicture *aPicture) sl@0: { sl@0: // currently type cast the pointer as buffer ID. sl@0: // FIXME once the new data structure is available. sl@0: return( (TInt) aPicture->iData.iRawData->Ptr()); sl@0: } sl@0: sl@0: TInt CNGAPostProcHwDevice::RegisterSurface(const TSurfaceId& aSurfaceId) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:RegisterSurface(): RegisterSurface ID = 0x%x"), this, aSurfaceId); sl@0: TInt err = KErrNone; sl@0: TInt numScreens = iWsSession.NumberOfScreens(); sl@0: for(TInt i=0; (i < numScreens && err == KErrNone); i++) sl@0: { sl@0: err = iWsSession.RegisterSurface(i, aSurfaceId); sl@0: } sl@0: return(err); sl@0: } sl@0: sl@0: TInt CNGAPostProcHwDevice::IsGceReady() sl@0: { sl@0: if(iProcessQ.Count() >= KMaxBuffersGceCanHold) sl@0: { sl@0: return EFalse; sl@0: } sl@0: return ETrue; sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::SetTimer(TInt64 aDelta) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetTimer .. aDelta=%d"), this, (TInt)aDelta); sl@0: if(aDelta <= KRenderAhead) sl@0: { sl@0: if(aDelta < 0) sl@0: { sl@0: iPostingTimer->After(aDelta * -1); sl@0: } sl@0: else sl@0: { sl@0: iPostingTimer->After((aDelta - KRenderAhead) * -1); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: iPostingTimer->After(aDelta - KRenderAhead - KPostingOfset); sl@0: } sl@0: } sl@0: // sl@0: // Convert YUV420 to YUV422InterLeaved. sl@0: // sl@0: TInt CNGAPostProcHwDevice::ConvertPostProcBuffer(TVideoPicture* pSrc, TVideoPicture* pDest) sl@0: { sl@0: PP_DEBUG(_L("CMdfPostingSurfaceProxy::ConvertPostProcBuffer ++")); sl@0: TInt err = KErrNone; sl@0: if (!pDest && !pSrc) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ConvertPostProcBuffer FAILED: Invalid pic pSrc %x pDest %x."), this, pSrc, pDest); sl@0: return KErrArgument; sl@0: } sl@0: sl@0: // --- Prepare wrappers --- sl@0: tBaseVideoFrame tFrame420, tFrame422; sl@0: TInt frameSize = pSrc->iData.iDataSize.iWidth * pSrc->iData.iDataSize.iHeight; sl@0: sl@0: PP_DEBUG(_L("CMdfPostingSurfaceProxy::ConvertPostProcBuffer .. w=%d, h=%d"), pSrc->iData.iDataSize.iWidth, pSrc->iData.iDataSize.iHeight); sl@0: sl@0: tFrame420.width = pSrc->iData.iDataSize.iWidth; sl@0: tFrame420.height= pSrc->iData.iDataSize.iHeight; sl@0: tFrame420.lum = (TUint8*)pSrc->iData.iRawData->Ptr(); sl@0: tFrame420.cb = (TUint8*)tFrame420.lum + frameSize; sl@0: tFrame420.cr = (TUint8*)tFrame420.lum + (frameSize*5)/4; sl@0: sl@0: tFrame422.width = pSrc->iData.iDataSize.iWidth; sl@0: tFrame422.height= pSrc->iData.iDataSize.iHeight; sl@0: tFrame422.lum = (TUint8*)pDest->iData.iRawData->Ptr(); sl@0: tFrame422.cb = 0; sl@0: tFrame422.cr = 0; sl@0: sl@0: // --- Convertion to posting buffer --- sl@0: TInt stride = pSrc->iData.iDataSize.iWidth * 2; sl@0: EBufferLayout422 layout = YUV422INT_BE; sl@0: sl@0: err = gColorConvYUVtoYUV422Int(&tFrame420, &tFrame422, layout, stride); sl@0: if(err != KErrNone) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice::ConvertPostProcBuffer .. err= %d."), err); sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::AddPictureToVBMQ(TVideoPicture *pic) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddPictureToVBMQ ++"), this); sl@0: iVBMBufferQ.Append(pic); sl@0: sl@0: if ( !iIsInputEnded && iPPState != EStopped ) sl@0: { sl@0: iVBMObserver->MmvbmoNewBuffers(); sl@0: } sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddPictureToVBMQ --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::AddPictureToColorConversionQ(TVideoPicture *pic) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddPictureToColorConversionQ ++"), this); sl@0: iColorConversionQ.Append(pic); sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddPictureToColorConversionQ --"), this); sl@0: } sl@0: sl@0: #ifdef _DUMP_YUV_FRAMES sl@0: void CNGAPostProcHwDevice::captureYuv(TVideoPicture* aPicture) sl@0: { sl@0: char buf[128]; sl@0: sprintf(buf, "c:\\fb%d.yuv", count++); sl@0: FILE *fp = ::fopen(buf, "w"); sl@0: TInt size = aPicture->iData.iRawData->Size(); sl@0: //{FILE* f1 = fopen(MY_LOG_FILE_NAME, "a+"));if(f1){fprintf(f1, "Size %d \n"), size );fclose(f1); }} sl@0: sl@0: ::fwrite(aPicture->iData.iRawData->Ptr(), 1, size, fp); sl@0: ::fclose(fp); sl@0: } sl@0: #endif sl@0: sl@0: void CNGAPostProcHwDevice::ResetCountingBuffer() sl@0: { sl@0: memset(iSkippedFramesCountingBuffer,0,sizeof(iSkippedFramesCountingBuffer)); sl@0: iSkippedFramesInLast64Frames = 0; sl@0: iCurrentPosInFramesCountingBuffer = 0; sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::PicturesSkipped() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PicturesSkipped ++"), this); sl@0: iPictureCounters.iPicturesSkipped++; sl@0: if (!iKeyFrameMode && iPlayRate>KDefPlayRate) sl@0: { sl@0: if (iSkippedFramesCountingBuffer[iCurrentPosInFramesCountingBuffer]==0) sl@0: { sl@0: iSkippedFramesCountingBuffer[iCurrentPosInFramesCountingBuffer] = 1; sl@0: iSkippedFramesInLast64Frames++; sl@0: if (iSkippedFramesInLast64Frames>KMaxAllowedSkipInNFrames && iFPObserver ) sl@0: { sl@0: iFPObserver->MmvproKeyFrameModeRequest(); sl@0: iKeyFrameMode=ETrue; sl@0: ResetCountingBuffer(); sl@0: } sl@0: } sl@0: iCurrentPosInFramesCountingBuffer = ++iCurrentPosInFramesCountingBuffer%64; sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:PicturesSkipped --"), this); sl@0: } sl@0: sl@0: TVideoPicture* CNGAPostProcHwDevice::DoColorConvert(TVideoPicture* aPicture) sl@0: { sl@0: TVideoPicture *pOutPicture = aPicture; sl@0: sl@0: if(iColorConversionQ.Count()) sl@0: { sl@0: pOutPicture = iColorConversionQ[0]; sl@0: iColorConversionQ.Remove(0); sl@0: ConvertPostProcBuffer(aPicture, pOutPicture); sl@0: pOutPicture->iTimestamp = aPicture->iTimestamp; sl@0: ReleasePicture(aPicture); sl@0: } sl@0: else sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:WritePictureL() FAILED: color conversion"), this); sl@0: } sl@0: sl@0: return pOutPicture; sl@0: } sl@0: sl@0: TInt CNGAPostProcHwDevice::AddToQ(TVideoPicture* aPicture) sl@0: { sl@0: TVideoPicture* pic = aPicture; sl@0: TInt pos = -1; sl@0: if(iInputQ.Count() == 0) sl@0: { sl@0: iInputQ.Append(pic); sl@0: } sl@0: else sl@0: { sl@0: pos = iInputQ.Count()-1; sl@0: for(; pos >= 0; pos--) sl@0: { sl@0: if(pic->iTimestamp.Int64() > iInputQ[pos]->iTimestamp.Int64()) sl@0: { sl@0: break; sl@0: } sl@0: } sl@0: if(iInputQ.Count() == pos+1) sl@0: { sl@0: iInputQ.Append(pic); sl@0: } sl@0: else sl@0: { sl@0: iInputQ.Insert(pic, pos+1); sl@0: } sl@0: } sl@0: return pos+1; sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::RemoveFromQ() sl@0: { sl@0: if(iInputQ.Count()) sl@0: { sl@0: if(iPlayRate > 0) sl@0: { sl@0: iInputQ.Remove(0); sl@0: } sl@0: else sl@0: { sl@0: iInputQ.Remove(iInputQ.Count()-1); sl@0: } sl@0: } sl@0: } sl@0: sl@0: TVideoPicture* CNGAPostProcHwDevice::PeekQ() sl@0: { sl@0: TVideoPicture *pic = NULL; sl@0: if(iInputQ.Count()) sl@0: { sl@0: if(iPlayRate > 0) sl@0: { sl@0: pic = iInputQ[0]; sl@0: } sl@0: else sl@0: { sl@0: pic = iInputQ[iInputQ.Count()-1]; sl@0: } sl@0: } sl@0: return pic; sl@0: } sl@0: sl@0: TInt CNGAPostProcHwDevice::AddHints() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints iSurfaceMask 0x%08x ++"), this, iSurfaceMask); sl@0: TInt err = KErrNone; sl@0: iHint.Set(iSurfaceKey,iSurfaceMask,ETrue); sl@0: err = iSurfaceHandler->AddSurfaceHint(iSurfaceId,iHint); sl@0: if(err == KErrAlreadyExists) sl@0: { sl@0: err = KErrNone; sl@0: err = iSurfaceHandler->SetSurfaceHint(iSurfaceId,iHint); sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints. err = %d --"), this,err); sl@0: iHint.iKey.iUid = surfaceHints::KSurfaceContent; sl@0: iHint.iValue = surfaceHints::EVideoPlayback; sl@0: iHint.iMutable = ETrue; sl@0: err = iSurfaceHandler->AddSurfaceHint(iSurfaceId,iHint); sl@0: if(err == KErrAlreadyExists) sl@0: { sl@0: err = KErrNone; sl@0: err = iSurfaceHandler->SetSurfaceHint(iSurfaceId,iHint); sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:AddHints. err = %d --"), this,err); sl@0: return err; sl@0: } sl@0: sl@0: TInt CNGAPostProcHwDevice::ColorConvert(tBaseVideoFrame* aInputFrame, TUint8* aDestPtr, tWndParam* aInputCropWindow, tWndParam* aOutputCropWindow) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ColorConvert ++"), this); sl@0: __ASSERT_ALWAYS(aDestPtr, User::Invariant()); sl@0: TInt lError = E_SUCCESS; sl@0: TInt err = KErrNone; sl@0: sl@0: err = SetSourceFormat(); sl@0: if(err == KErrNone) sl@0: { sl@0: err = SetSourceRange(); sl@0: if(err == KErrNone) sl@0: { sl@0: sl@0: lError = Emz_VDec_gColorConv_YUVtoRGB(aInputFrame,aDestPtr, sl@0: aInputCropWindow, aOutputCropWindow, iSourceFormat, sl@0: EBitmapColor16MU, iSourceRange); sl@0: sl@0: if(lError) sl@0: { sl@0: if(lError == E_OUT_OF_MEMORY) sl@0: { sl@0: err = KErrNoMemory; sl@0: } sl@0: else if(lError == E_FAILURE) sl@0: { sl@0: err = KErrNotSupported; sl@0: } sl@0: else sl@0: { sl@0: err = KErrGeneral; sl@0: } sl@0: } sl@0: } sl@0: } sl@0: sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:ColorConvert --"), this); sl@0: return err; sl@0: } sl@0: sl@0: TInt CNGAPostProcHwDevice::SetSourceFormat() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceFormatL ++"), this); sl@0: TInt err = KErrNone; sl@0: switch (iVideoFormat.iYuvFormat.iPattern) sl@0: { sl@0: case EYuv420Chroma1: sl@0: iSourceFormat = EYuv420Chroma1_Planar; sl@0: break; sl@0: case EYuv420Chroma2: sl@0: iSourceFormat = EYuv420Chroma2_Planar; sl@0: break; sl@0: case EYuv420Chroma3: sl@0: iSourceFormat = EYuv420Chroma3_Planar; sl@0: break; sl@0: case EYuv422Chroma1: sl@0: if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedLE) sl@0: iSourceFormat = EYuv422Chroma1_LE; sl@0: else if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedBE ) sl@0: iSourceFormat = EYuv422Chroma1_BE; sl@0: else sl@0: err = KErrArgument; sl@0: break; sl@0: case EYuv422Chroma2: sl@0: if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedLE) sl@0: iSourceFormat = EYuv422Chroma2_LE; sl@0: else if( iVideoFormat.iYuvFormat.iDataLayout == EYuvDataInterleavedBE ) sl@0: iSourceFormat = EYuv422Chroma2_BE; sl@0: else sl@0: err = KErrArgument; sl@0: break; sl@0: default: sl@0: err = KErrNotSupported; sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceFormatL --"), this); sl@0: return err; sl@0: } sl@0: sl@0: sl@0: TInt CNGAPostProcHwDevice::SetSourceRange() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceRangeL ++"), this); sl@0: TInt err = KErrNone; sl@0: switch (iVideoFormat.iYuvFormat.iCoefficients) sl@0: { sl@0: case EYuvBt601Range0: sl@0: iSourceRange = EITU601_5_REDUCEDRANGE; sl@0: break; sl@0: case EYuvBt601Range1: sl@0: iSourceRange = EITU601_5_FULLRANGE; sl@0: break; sl@0: case EYuvBt709Range0: sl@0: iSourceRange = EB709_REDUCEDRANGE; sl@0: break; sl@0: case EYuvBt709Range1: sl@0: iSourceRange = EB709_FULLRANGE; sl@0: break; sl@0: default: sl@0: err = KErrNotSupported; sl@0: } sl@0: PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:SetSourceRangeL --"), this); sl@0: return err; sl@0: } sl@0: sl@0: CNGAPostProcTimer::CNGAPostProcTimer( CNGAPostProcHwDevice& aParent ) sl@0: :CTimer(EPriorityHigh),iParent(aParent) sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: CNGAPostProcTimer::~CNGAPostProcTimer() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcTimer[%x]:~CNGAPostProcTimer ++"), this); sl@0: Cancel(); sl@0: PP_DEBUG(_L("CNGAPostProcTimer[%x]:~CNGAPostProcTimer --"), this); sl@0: } sl@0: sl@0: CNGAPostProcTimer* CNGAPostProcTimer::NewL( CNGAPostProcHwDevice& aParent ) sl@0: { sl@0: CNGAPostProcTimer* self = new (ELeave)CNGAPostProcTimer(aParent); sl@0: CleanupStack::PushL( self ); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop( self ); sl@0: return self; sl@0: } sl@0: sl@0: void CNGAPostProcTimer::ConstructL() sl@0: { sl@0: CTimer::ConstructL(); sl@0: } sl@0: sl@0: void CNGAPostProcTimer::RunL() sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcTimer[%x]:RunL ++"), this); sl@0: if (iStatus ==KErrCancel) sl@0: { sl@0: PP_DEBUG(_L("CNGAPostProcNotifier[%x]:CNGAPostProcNotifier:RunL State canceled"), this); sl@0: return; sl@0: } sl@0: iParent.AttemptToPost(); sl@0: PP_DEBUG(_L("CNGAPostProcTimer[%x]:RunL --"), this); sl@0: } sl@0: sl@0: void CNGAPostProcHwDevice::MmpirPostInitializeRequest(MMmfPostInitializeResponse& aResponse) sl@0: { sl@0: iPostInitializeResponse = &aResponse; sl@0: }