os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevVideo/src/TestDevVideoPlugins/preproc.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include "preproc.h"
    17 #include "../TestDevVideoPlayTestData.h"
    18 
    19 _LIT(KDevVideoPreProcPanicCategory, "DevVideoPreProcessor");
    20 void DevVideoPreProcPanic(TInt aReason)
    21 	{
    22 	User::Panic(KDevVideoPreProcPanicCategory, aReason);
    23 	}
    24 
    25 CMMFVideoPreProcHwDevice* CMMFTestVideoPreProcHwDevice::NewL(TAny* /*aInitParams*/)
    26 	{
    27 	CMMFTestVideoPreProcHwDevice* s = new(ELeave) CMMFTestVideoPreProcHwDevice;
    28 	return (STATIC_CAST(CMMFVideoPreProcHwDevice*, s));
    29 	}
    30 
    31 CMMFTestVideoPreProcHwDevice::CMMFTestVideoPreProcHwDevice()
    32 	:iRecPosition(KTestRecordPosition)
    33 	{
    34 	}
    35 
    36 CMMFTestVideoPreProcHwDevice::~CMMFTestVideoPreProcHwDevice()
    37 	{
    38 	iInputVidFormats.Reset();
    39 	iInputVidFormats.Close();
    40 
    41 	iOutputVidFormats.Reset();
    42 	iOutputVidFormats.Close();
    43 
    44 	iScaleFactors.Reset();
    45 	iScaleFactors.Close();
    46 
    47 	iCombinations.Reset();
    48 	iCombinations.Close();
    49 	}
    50 
    51 TAny* CMMFTestVideoPreProcHwDevice::CustomInterface(TUid aInterface)
    52 	{
    53 	if (aInterface == KUidCustomInterfaceFour)
    54 		{
    55 		return this;//just want to return something non-null!
    56 		}
    57 	else
    58 		{
    59 		return NULL;
    60 		}
    61 	}
    62 
    63 CPreProcessorInfo* CMMFTestVideoPreProcHwDevice::PreProcessorInfoLC()
    64 	{
    65 	// construct array of test types
    66 	for (TUint i = 0; i < KTestPostProcInfoCount; i++)
    67 		{
    68 		// append the input video formats
    69 		TUncompressedVideoFormat vid = KTestPreProcInfoInputFormatArray[i];
    70 		User::LeaveIfError(iInputVidFormats.Append(vid));
    71 		
    72 		// append the output video formats
    73 		vid = KTestPreProcInfoOutputFormatArray[i];
    74 		User::LeaveIfError(iOutputVidFormats.Append(vid));
    75 
    76 		// append the combinations
    77 		TUint32 comb = KTestPostProcInfoCombsArray[i];
    78 		User::LeaveIfError(iCombinations.Append(comb));
    79 
    80 		// append the scale factors
    81 		TScaleFactor scale = KTestPostProcInfoScaleFactorsArray[i];
    82 		User::LeaveIfError(iScaleFactors.Append(scale));
    83 		}
    84 	
    85 	// construct the video decoder info object
    86 	CPreProcessorInfo* vInfo = CPreProcessorInfo::NewL(
    87 		KUidDevVideoTestPreProcHwDevice,
    88 		KTestPreProcInfoManufacturer,
    89 		KTestPreProcInfoIdentifier,
    90 		TVersion(KTestPreProcInfoVersionMaj, KTestPreProcInfoVersionMin, KTestPreProcInfoVersionBuild),
    91 		ETrue,	// accelerated
    92 		ETrue,	// supports direct capture
    93 		iInputVidFormats.Array(),
    94 		iOutputVidFormats.Array(),
    95 		iCombinations.Array(),
    96 		ETrue,	// scaling
    97 		ETrue,	// anti-aliasing
    98 		iScaleFactors.Array(),
    99 		KTestPreProcInfoYuvToYuvCaps,
   100 		KTestPreProcInfoRgbRanges,
   101 		KTestPreProcInfoRotations,
   102 		KTestPreProcInfoISInfo );
   103 		
   104 	CleanupStack::PushL(vInfo);
   105 	return vInfo;
   106 	}
   107 
   108 void CMMFTestVideoPreProcHwDevice::SetInputFormatL(const TUncompressedVideoFormat& aFormat, const TSize& aPictureSize)
   109 	{
   110 	TSize testSize(KTestInputSize2X, KTestInputSize2Y);
   111 
   112 	if (!(aFormat == KTestVidFormat2) || !(aPictureSize == testSize))
   113 		User::Leave(KErrCorrupt);
   114 	}
   115 
   116 void CMMFTestVideoPreProcHwDevice::SetSourceCameraL(TInt aCameraHandle, TReal aPictureRate)
   117 	{
   118 	if (aCameraHandle == KTestCamHandleFatal)
   119 		iProxy->MdvrpFatalError(this, KErrDied);
   120 	else if ((KTestCamHandlePre != aCameraHandle) || (KTestPictureRate != aPictureRate))
   121 		User::Leave(KErrCorrupt);
   122 	}
   123 
   124 void CMMFTestVideoPreProcHwDevice::SetSourceMemoryL(TReal aMaxPictureRate, TBool aConstantPictureRate, TBool aProcessRealtime)
   125 	{
   126 	if ((KTestPictureRate != aMaxPictureRate) || !aConstantPictureRate || aProcessRealtime)
   127 		User::Leave(KErrCorrupt);
   128 	}
   129 
   130 void CMMFTestVideoPreProcHwDevice::SetClockSource(MMMFClockSource* aClock)
   131 	{
   132 	__ASSERT_ALWAYS(aClock, DevVideoPreProcPanic(EPreProcPanicClockSource)); 
   133 
   134 	// call Time() to check that clock can be used
   135 	TTimeIntervalMicroSeconds currTime(0); // done this way to remove compiler warning
   136 	currTime = aClock->Time();
   137 	}
   138 
   139 void CMMFTestVideoPreProcHwDevice::SetPreProcessTypesL(TUint32 aPreProcessTypes)
   140 	{
   141 	if (!(aPreProcessTypes == KTestProcessType2))
   142 		User::Leave(KErrCorrupt);
   143 	}
   144 
   145 void CMMFTestVideoPreProcHwDevice::SetRgbToYuvOptionsL(TRgbRange aRange, const TYuvFormat& aOutputFormat)
   146 	{
   147 	// check against test data
   148 	if ((aRange != KTestRgbRange2) || !CompareYuvFormats(aOutputFormat, KTestYuvFormat2) )
   149 		User::Leave(KErrCorrupt);
   150 	}
   151 
   152 void CMMFTestVideoPreProcHwDevice::SetYuvToYuvOptionsL(const TYuvFormat& aInputFormat, const TYuvFormat& aOutputFormat)
   153 	{
   154 	if (!CompareYuvFormats(aInputFormat, KTestYuvFormat2) || !CompareYuvFormats(aOutputFormat, KTestYuvFormat1) )
   155 		User::Leave(KErrCorrupt);
   156 	}
   157 
   158 void CMMFTestVideoPreProcHwDevice::SetRotateOptionsL(TRotationType aRotationType)
   159 	{
   160 	if (!(aRotationType == KTestRotate2))
   161 		User::Leave(KErrCorrupt);
   162 	}
   163 
   164 void CMMFTestVideoPreProcHwDevice::SetScaleOptionsL(const TSize& aTargetSize, TBool aAntiAliasFiltering)
   165 	{
   166 	TSize testScale(KTestScaleY, KTestScaleX);
   167 	if (!(aTargetSize == testScale) || !aAntiAliasFiltering)
   168 		User::Leave(KErrCorrupt);
   169 	}
   170 
   171 void CMMFTestVideoPreProcHwDevice::SetInputCropOptionsL(const TRect& aRect)
   172 	{
   173 	TRect testRect(KTestInputCropRectD, KTestInputCropRectC, KTestInputCropRectB, KTestInputCropRectA);
   174 	if (!(aRect == testRect))
   175 		User::Leave(KErrCorrupt);
   176 	}
   177 
   178 void CMMFTestVideoPreProcHwDevice::SetOutputCropOptionsL(const TRect& aRect)
   179 	{
   180 	TRect testRect(KTestOutputCropRectD, KTestOutputCropRectC, KTestOutputCropRectB, KTestOutputCropRectA);
   181 	if (!(aRect == testRect))
   182 		User::Leave(KErrCorrupt);
   183 	}
   184 
   185 void CMMFTestVideoPreProcHwDevice::SetOutputPadOptionsL(const TSize& aOutputSize, const TPoint& aPicturePos)
   186 	{
   187 	TSize testPad(KTestPadY, KTestPadX);
   188 	TPoint testPoint(KTestPadPointY, KTestPadPointX);
   189 
   190 	if (!(testPad == aOutputSize) || !(testPoint == aPicturePos))
   191 		User::Leave(KErrCorrupt);
   192 	}
   193 
   194 void CMMFTestVideoPreProcHwDevice::SetColorEnhancementOptionsL(const TColorEnhancementOptions& aOptions)
   195 	{
   196 	if (!CompareColorEnhancements(aOptions, KTestColorEnhance2))
   197 		User::Leave(KErrCorrupt);
   198 	}
   199 
   200 void CMMFTestVideoPreProcHwDevice::SetFrameStabilisationOptionsL(const TSize& aOutputSize, TBool aFrameStabilisation)
   201 	{
   202 	TSize testSize(KTestScaleY, KTestScaleX);
   203 	if (!(aOutputSize == testSize) || !aFrameStabilisation)
   204 		User::Leave(KErrCorrupt);
   205 	}
   206 
   207 void CMMFTestVideoPreProcHwDevice::SetCustomPreProcessOptionsL(const TDesC8& aOptions)
   208 	{
   209 	if (!(aOptions == KTestCustomPreProc2))
   210 		User::Leave(KErrCorrupt);
   211 	}
   212 
   213 void CMMFTestVideoPreProcHwDevice::Initialize()
   214 	{
   215 	iProxy->MdvrpInitializeComplete(this, KErrNone);
   216 	}
   217 
   218 void CMMFTestVideoPreProcHwDevice::WritePictureL(TVideoPicture* aPicture)
   219 	{
   220 	iProxy->MdvrpReturnPicture(aPicture);
   221 	}
   222 
   223 void CMMFTestVideoPreProcHwDevice::InputEnd()
   224 	{
   225 	iProxy->MdvrpStreamEnd();
   226 	}
   227 
   228 void CMMFTestVideoPreProcHwDevice::Start()
   229 	{
   230 	iRecPosition = KTestRecTimeStartPre;
   231 	iIsRecording = ETrue;
   232 	}
   233 
   234 void CMMFTestVideoPreProcHwDevice::Stop()
   235 	{
   236 	iRecPosition = KTestRecTimeStop;
   237 	iIsRecording = EFalse;
   238 	}
   239 
   240 void CMMFTestVideoPreProcHwDevice::Pause()
   241 	{
   242 	iRecPosition = KTestRecTimePausePre;
   243 	iIsRecording = EFalse;
   244 	}
   245 
   246 void CMMFTestVideoPreProcHwDevice::Resume()
   247 	{
   248 	iRecPosition = KTestRecTimeResumePre;
   249 	iIsRecording = ETrue;
   250 	}
   251 
   252 void CMMFTestVideoPreProcHwDevice::Freeze()
   253 	{
   254 	}
   255 
   256 void CMMFTestVideoPreProcHwDevice::ReleaseFreeze()
   257 	{
   258 	}
   259 
   260 TTimeIntervalMicroSeconds CMMFTestVideoPreProcHwDevice::RecordingPosition()
   261 	{
   262 	return iRecPosition;
   263 	}
   264 
   265 void CMMFTestVideoPreProcHwDevice::GetPictureCounters(CMMFDevVideoRecord::TPictureCounters& aCounters)
   266 	{
   267 	aCounters = GetTestEncPictureCounters();
   268 	}
   269 
   270 void CMMFTestVideoPreProcHwDevice::GetFrameStabilisationOutput(TRect& aRect)
   271 	{
   272 	aRect = TRect(KTestFrameStableY1, KTestFrameStableX1, KTestFrameStableY2, KTestFrameStableX2);
   273 	}
   274 
   275 TUint CMMFTestVideoPreProcHwDevice::NumComplexityLevels()
   276 	{
   277 	return KTestNumComplexityLevels2;
   278 	}
   279 
   280 void CMMFTestVideoPreProcHwDevice::SetComplexityLevel(TUint aLevel)
   281 	{
   282 	__ASSERT_ALWAYS(aLevel == KTestComplexityLevel2, DevVideoPreProcPanic(EPreProcPanicComplexityLevel));
   283 	}
   284 
   285 void CMMFTestVideoPreProcHwDevice::SetOutputFormatL(const TUncompressedVideoFormat& aFormat)
   286 	{
   287 	if (!(aFormat == KTestVidFormat2))
   288 		{
   289 		User::Leave(KErrCorrupt);
   290 		}
   291 	}
   292 
   293 void CMMFTestVideoPreProcHwDevice::SetOutputDevice(CMMFVideoEncodeHwDevice* /*aDevice*/)
   294 	{
   295 	}
   296 
   297 void CMMFTestVideoPreProcHwDevice::ReturnPicture(TVideoPicture* /*aPicture*/)
   298 	{
   299 	}
   300 
   301 void CMMFTestVideoPreProcHwDevice::CommitL()
   302 	{
   303 	}
   304 
   305 void CMMFTestVideoPreProcHwDevice::Revert()
   306 	{
   307 	}
   308 
   309 void CMMFTestVideoPreProcHwDevice::SetProxy(MMMFDevVideoRecordProxy& aProxy)
   310 	{
   311 	ASSERT(iProxy == NULL);
   312 	iProxy = &aProxy;
   313 	}
   314