sl@0: // Copyright (c) 2003-2009 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: #include "preproc.h"
sl@0: #include "../TestDevVideoPlayTestData.h"
sl@0: 
sl@0: _LIT(KDevVideoPreProcPanicCategory, "DevVideoPreProcessor");
sl@0: void DevVideoPreProcPanic(TInt aReason)
sl@0: 	{
sl@0: 	User::Panic(KDevVideoPreProcPanicCategory, aReason);
sl@0: 	}
sl@0: 
sl@0: CMMFVideoPreProcHwDevice* CMMFTestVideoPreProcHwDevice::NewL(TAny* /*aInitParams*/)
sl@0: 	{
sl@0: 	CMMFTestVideoPreProcHwDevice* s = new(ELeave) CMMFTestVideoPreProcHwDevice;
sl@0: 	return (STATIC_CAST(CMMFVideoPreProcHwDevice*, s));
sl@0: 	}
sl@0: 
sl@0: CMMFTestVideoPreProcHwDevice::CMMFTestVideoPreProcHwDevice()
sl@0: 	:iRecPosition(KTestRecordPosition)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: CMMFTestVideoPreProcHwDevice::~CMMFTestVideoPreProcHwDevice()
sl@0: 	{
sl@0: 	iInputVidFormats.Reset();
sl@0: 	iInputVidFormats.Close();
sl@0: 
sl@0: 	iOutputVidFormats.Reset();
sl@0: 	iOutputVidFormats.Close();
sl@0: 
sl@0: 	iScaleFactors.Reset();
sl@0: 	iScaleFactors.Close();
sl@0: 
sl@0: 	iCombinations.Reset();
sl@0: 	iCombinations.Close();
sl@0: 	}
sl@0: 
sl@0: TAny* CMMFTestVideoPreProcHwDevice::CustomInterface(TUid aInterface)
sl@0: 	{
sl@0: 	if (aInterface == KUidCustomInterfaceFour)
sl@0: 		{
sl@0: 		return this;//just want to return something non-null!
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		return NULL;
sl@0: 		}
sl@0: 	}
sl@0: 
sl@0: CPreProcessorInfo* CMMFTestVideoPreProcHwDevice::PreProcessorInfoLC()
sl@0: 	{
sl@0: 	// construct array of test types
sl@0: 	for (TUint i = 0; i < KTestPostProcInfoCount; i++)
sl@0: 		{
sl@0: 		// append the input video formats
sl@0: 		TUncompressedVideoFormat vid = KTestPreProcInfoInputFormatArray[i];
sl@0: 		User::LeaveIfError(iInputVidFormats.Append(vid));
sl@0: 		
sl@0: 		// append the output video formats
sl@0: 		vid = KTestPreProcInfoOutputFormatArray[i];
sl@0: 		User::LeaveIfError(iOutputVidFormats.Append(vid));
sl@0: 
sl@0: 		// append the combinations
sl@0: 		TUint32 comb = KTestPostProcInfoCombsArray[i];
sl@0: 		User::LeaveIfError(iCombinations.Append(comb));
sl@0: 
sl@0: 		// append the scale factors
sl@0: 		TScaleFactor scale = KTestPostProcInfoScaleFactorsArray[i];
sl@0: 		User::LeaveIfError(iScaleFactors.Append(scale));
sl@0: 		}
sl@0: 	
sl@0: 	// construct the video decoder info object
sl@0: 	CPreProcessorInfo* vInfo = CPreProcessorInfo::NewL(
sl@0: 		KUidDevVideoTestPreProcHwDevice,
sl@0: 		KTestPreProcInfoManufacturer,
sl@0: 		KTestPreProcInfoIdentifier,
sl@0: 		TVersion(KTestPreProcInfoVersionMaj, KTestPreProcInfoVersionMin, KTestPreProcInfoVersionBuild),
sl@0: 		ETrue,	// accelerated
sl@0: 		ETrue,	// supports direct capture
sl@0: 		iInputVidFormats.Array(),
sl@0: 		iOutputVidFormats.Array(),
sl@0: 		iCombinations.Array(),
sl@0: 		ETrue,	// scaling
sl@0: 		ETrue,	// anti-aliasing
sl@0: 		iScaleFactors.Array(),
sl@0: 		KTestPreProcInfoYuvToYuvCaps,
sl@0: 		KTestPreProcInfoRgbRanges,
sl@0: 		KTestPreProcInfoRotations,
sl@0: 		KTestPreProcInfoISInfo );
sl@0: 		
sl@0: 	CleanupStack::PushL(vInfo);
sl@0: 	return vInfo;
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetInputFormatL(const TUncompressedVideoFormat& aFormat, const TSize& aPictureSize)
sl@0: 	{
sl@0: 	TSize testSize(KTestInputSize2X, KTestInputSize2Y);
sl@0: 
sl@0: 	if (!(aFormat == KTestVidFormat2) || !(aPictureSize == testSize))
sl@0: 		User::Leave(KErrCorrupt);
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetSourceCameraL(TInt aCameraHandle, TReal aPictureRate)
sl@0: 	{
sl@0: 	if (aCameraHandle == KTestCamHandleFatal)
sl@0: 		iProxy->MdvrpFatalError(this, KErrDied);
sl@0: 	else if ((KTestCamHandlePre != aCameraHandle) || (KTestPictureRate != aPictureRate))
sl@0: 		User::Leave(KErrCorrupt);
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetSourceMemoryL(TReal aMaxPictureRate, TBool aConstantPictureRate, TBool aProcessRealtime)
sl@0: 	{
sl@0: 	if ((KTestPictureRate != aMaxPictureRate) || !aConstantPictureRate || aProcessRealtime)
sl@0: 		User::Leave(KErrCorrupt);
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetClockSource(MMMFClockSource* aClock)
sl@0: 	{
sl@0: 	__ASSERT_ALWAYS(aClock, DevVideoPreProcPanic(EPreProcPanicClockSource)); 
sl@0: 
sl@0: 	// call Time() to check that clock can be used
sl@0: 	TTimeIntervalMicroSeconds currTime(0); // done this way to remove compiler warning
sl@0: 	currTime = aClock->Time();
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetPreProcessTypesL(TUint32 aPreProcessTypes)
sl@0: 	{
sl@0: 	if (!(aPreProcessTypes == KTestProcessType2))
sl@0: 		User::Leave(KErrCorrupt);
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetRgbToYuvOptionsL(TRgbRange aRange, const TYuvFormat& aOutputFormat)
sl@0: 	{
sl@0: 	// check against test data
sl@0: 	if ((aRange != KTestRgbRange2) || !CompareYuvFormats(aOutputFormat, KTestYuvFormat2) )
sl@0: 		User::Leave(KErrCorrupt);
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetYuvToYuvOptionsL(const TYuvFormat& aInputFormat, const TYuvFormat& aOutputFormat)
sl@0: 	{
sl@0: 	if (!CompareYuvFormats(aInputFormat, KTestYuvFormat2) || !CompareYuvFormats(aOutputFormat, KTestYuvFormat1) )
sl@0: 		User::Leave(KErrCorrupt);
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetRotateOptionsL(TRotationType aRotationType)
sl@0: 	{
sl@0: 	if (!(aRotationType == KTestRotate2))
sl@0: 		User::Leave(KErrCorrupt);
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetScaleOptionsL(const TSize& aTargetSize, TBool aAntiAliasFiltering)
sl@0: 	{
sl@0: 	TSize testScale(KTestScaleY, KTestScaleX);
sl@0: 	if (!(aTargetSize == testScale) || !aAntiAliasFiltering)
sl@0: 		User::Leave(KErrCorrupt);
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetInputCropOptionsL(const TRect& aRect)
sl@0: 	{
sl@0: 	TRect testRect(KTestInputCropRectD, KTestInputCropRectC, KTestInputCropRectB, KTestInputCropRectA);
sl@0: 	if (!(aRect == testRect))
sl@0: 		User::Leave(KErrCorrupt);
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetOutputCropOptionsL(const TRect& aRect)
sl@0: 	{
sl@0: 	TRect testRect(KTestOutputCropRectD, KTestOutputCropRectC, KTestOutputCropRectB, KTestOutputCropRectA);
sl@0: 	if (!(aRect == testRect))
sl@0: 		User::Leave(KErrCorrupt);
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetOutputPadOptionsL(const TSize& aOutputSize, const TPoint& aPicturePos)
sl@0: 	{
sl@0: 	TSize testPad(KTestPadY, KTestPadX);
sl@0: 	TPoint testPoint(KTestPadPointY, KTestPadPointX);
sl@0: 
sl@0: 	if (!(testPad == aOutputSize) || !(testPoint == aPicturePos))
sl@0: 		User::Leave(KErrCorrupt);
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetColorEnhancementOptionsL(const TColorEnhancementOptions& aOptions)
sl@0: 	{
sl@0: 	if (!CompareColorEnhancements(aOptions, KTestColorEnhance2))
sl@0: 		User::Leave(KErrCorrupt);
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetFrameStabilisationOptionsL(const TSize& aOutputSize, TBool aFrameStabilisation)
sl@0: 	{
sl@0: 	TSize testSize(KTestScaleY, KTestScaleX);
sl@0: 	if (!(aOutputSize == testSize) || !aFrameStabilisation)
sl@0: 		User::Leave(KErrCorrupt);
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetCustomPreProcessOptionsL(const TDesC8& aOptions)
sl@0: 	{
sl@0: 	if (!(aOptions == KTestCustomPreProc2))
sl@0: 		User::Leave(KErrCorrupt);
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::Initialize()
sl@0: 	{
sl@0: 	iProxy->MdvrpInitializeComplete(this, KErrNone);
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::WritePictureL(TVideoPicture* aPicture)
sl@0: 	{
sl@0: 	iProxy->MdvrpReturnPicture(aPicture);
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::InputEnd()
sl@0: 	{
sl@0: 	iProxy->MdvrpStreamEnd();
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::Start()
sl@0: 	{
sl@0: 	iRecPosition = KTestRecTimeStartPre;
sl@0: 	iIsRecording = ETrue;
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::Stop()
sl@0: 	{
sl@0: 	iRecPosition = KTestRecTimeStop;
sl@0: 	iIsRecording = EFalse;
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::Pause()
sl@0: 	{
sl@0: 	iRecPosition = KTestRecTimePausePre;
sl@0: 	iIsRecording = EFalse;
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::Resume()
sl@0: 	{
sl@0: 	iRecPosition = KTestRecTimeResumePre;
sl@0: 	iIsRecording = ETrue;
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::Freeze()
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::ReleaseFreeze()
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: TTimeIntervalMicroSeconds CMMFTestVideoPreProcHwDevice::RecordingPosition()
sl@0: 	{
sl@0: 	return iRecPosition;
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::GetPictureCounters(CMMFDevVideoRecord::TPictureCounters& aCounters)
sl@0: 	{
sl@0: 	aCounters = GetTestEncPictureCounters();
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::GetFrameStabilisationOutput(TRect& aRect)
sl@0: 	{
sl@0: 	aRect = TRect(KTestFrameStableY1, KTestFrameStableX1, KTestFrameStableY2, KTestFrameStableX2);
sl@0: 	}
sl@0: 
sl@0: TUint CMMFTestVideoPreProcHwDevice::NumComplexityLevels()
sl@0: 	{
sl@0: 	return KTestNumComplexityLevels2;
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetComplexityLevel(TUint aLevel)
sl@0: 	{
sl@0: 	__ASSERT_ALWAYS(aLevel == KTestComplexityLevel2, DevVideoPreProcPanic(EPreProcPanicComplexityLevel));
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetOutputFormatL(const TUncompressedVideoFormat& aFormat)
sl@0: 	{
sl@0: 	if (!(aFormat == KTestVidFormat2))
sl@0: 		{
sl@0: 		User::Leave(KErrCorrupt);
sl@0: 		}
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetOutputDevice(CMMFVideoEncodeHwDevice* /*aDevice*/)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::ReturnPicture(TVideoPicture* /*aPicture*/)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::CommitL()
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::Revert()
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: void CMMFTestVideoPreProcHwDevice::SetProxy(MMMFDevVideoRecordProxy& aProxy)
sl@0: 	{
sl@0: 	ASSERT(iProxy == NULL);
sl@0: 	iProxy = &aProxy;
sl@0: 	}
sl@0: