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