1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevVideo/src/TestDevVideoPlugins/preproc.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,314 @@
1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include "preproc.h"
1.20 +#include "../TestDevVideoPlayTestData.h"
1.21 +
1.22 +_LIT(KDevVideoPreProcPanicCategory, "DevVideoPreProcessor");
1.23 +void DevVideoPreProcPanic(TInt aReason)
1.24 + {
1.25 + User::Panic(KDevVideoPreProcPanicCategory, aReason);
1.26 + }
1.27 +
1.28 +CMMFVideoPreProcHwDevice* CMMFTestVideoPreProcHwDevice::NewL(TAny* /*aInitParams*/)
1.29 + {
1.30 + CMMFTestVideoPreProcHwDevice* s = new(ELeave) CMMFTestVideoPreProcHwDevice;
1.31 + return (STATIC_CAST(CMMFVideoPreProcHwDevice*, s));
1.32 + }
1.33 +
1.34 +CMMFTestVideoPreProcHwDevice::CMMFTestVideoPreProcHwDevice()
1.35 + :iRecPosition(KTestRecordPosition)
1.36 + {
1.37 + }
1.38 +
1.39 +CMMFTestVideoPreProcHwDevice::~CMMFTestVideoPreProcHwDevice()
1.40 + {
1.41 + iInputVidFormats.Reset();
1.42 + iInputVidFormats.Close();
1.43 +
1.44 + iOutputVidFormats.Reset();
1.45 + iOutputVidFormats.Close();
1.46 +
1.47 + iScaleFactors.Reset();
1.48 + iScaleFactors.Close();
1.49 +
1.50 + iCombinations.Reset();
1.51 + iCombinations.Close();
1.52 + }
1.53 +
1.54 +TAny* CMMFTestVideoPreProcHwDevice::CustomInterface(TUid aInterface)
1.55 + {
1.56 + if (aInterface == KUidCustomInterfaceFour)
1.57 + {
1.58 + return this;//just want to return something non-null!
1.59 + }
1.60 + else
1.61 + {
1.62 + return NULL;
1.63 + }
1.64 + }
1.65 +
1.66 +CPreProcessorInfo* CMMFTestVideoPreProcHwDevice::PreProcessorInfoLC()
1.67 + {
1.68 + // construct array of test types
1.69 + for (TUint i = 0; i < KTestPostProcInfoCount; i++)
1.70 + {
1.71 + // append the input video formats
1.72 + TUncompressedVideoFormat vid = KTestPreProcInfoInputFormatArray[i];
1.73 + User::LeaveIfError(iInputVidFormats.Append(vid));
1.74 +
1.75 + // append the output video formats
1.76 + vid = KTestPreProcInfoOutputFormatArray[i];
1.77 + User::LeaveIfError(iOutputVidFormats.Append(vid));
1.78 +
1.79 + // append the combinations
1.80 + TUint32 comb = KTestPostProcInfoCombsArray[i];
1.81 + User::LeaveIfError(iCombinations.Append(comb));
1.82 +
1.83 + // append the scale factors
1.84 + TScaleFactor scale = KTestPostProcInfoScaleFactorsArray[i];
1.85 + User::LeaveIfError(iScaleFactors.Append(scale));
1.86 + }
1.87 +
1.88 + // construct the video decoder info object
1.89 + CPreProcessorInfo* vInfo = CPreProcessorInfo::NewL(
1.90 + KUidDevVideoTestPreProcHwDevice,
1.91 + KTestPreProcInfoManufacturer,
1.92 + KTestPreProcInfoIdentifier,
1.93 + TVersion(KTestPreProcInfoVersionMaj, KTestPreProcInfoVersionMin, KTestPreProcInfoVersionBuild),
1.94 + ETrue, // accelerated
1.95 + ETrue, // supports direct capture
1.96 + iInputVidFormats.Array(),
1.97 + iOutputVidFormats.Array(),
1.98 + iCombinations.Array(),
1.99 + ETrue, // scaling
1.100 + ETrue, // anti-aliasing
1.101 + iScaleFactors.Array(),
1.102 + KTestPreProcInfoYuvToYuvCaps,
1.103 + KTestPreProcInfoRgbRanges,
1.104 + KTestPreProcInfoRotations,
1.105 + KTestPreProcInfoISInfo );
1.106 +
1.107 + CleanupStack::PushL(vInfo);
1.108 + return vInfo;
1.109 + }
1.110 +
1.111 +void CMMFTestVideoPreProcHwDevice::SetInputFormatL(const TUncompressedVideoFormat& aFormat, const TSize& aPictureSize)
1.112 + {
1.113 + TSize testSize(KTestInputSize2X, KTestInputSize2Y);
1.114 +
1.115 + if (!(aFormat == KTestVidFormat2) || !(aPictureSize == testSize))
1.116 + User::Leave(KErrCorrupt);
1.117 + }
1.118 +
1.119 +void CMMFTestVideoPreProcHwDevice::SetSourceCameraL(TInt aCameraHandle, TReal aPictureRate)
1.120 + {
1.121 + if (aCameraHandle == KTestCamHandleFatal)
1.122 + iProxy->MdvrpFatalError(this, KErrDied);
1.123 + else if ((KTestCamHandlePre != aCameraHandle) || (KTestPictureRate != aPictureRate))
1.124 + User::Leave(KErrCorrupt);
1.125 + }
1.126 +
1.127 +void CMMFTestVideoPreProcHwDevice::SetSourceMemoryL(TReal aMaxPictureRate, TBool aConstantPictureRate, TBool aProcessRealtime)
1.128 + {
1.129 + if ((KTestPictureRate != aMaxPictureRate) || !aConstantPictureRate || aProcessRealtime)
1.130 + User::Leave(KErrCorrupt);
1.131 + }
1.132 +
1.133 +void CMMFTestVideoPreProcHwDevice::SetClockSource(MMMFClockSource* aClock)
1.134 + {
1.135 + __ASSERT_ALWAYS(aClock, DevVideoPreProcPanic(EPreProcPanicClockSource));
1.136 +
1.137 + // call Time() to check that clock can be used
1.138 + TTimeIntervalMicroSeconds currTime(0); // done this way to remove compiler warning
1.139 + currTime = aClock->Time();
1.140 + }
1.141 +
1.142 +void CMMFTestVideoPreProcHwDevice::SetPreProcessTypesL(TUint32 aPreProcessTypes)
1.143 + {
1.144 + if (!(aPreProcessTypes == KTestProcessType2))
1.145 + User::Leave(KErrCorrupt);
1.146 + }
1.147 +
1.148 +void CMMFTestVideoPreProcHwDevice::SetRgbToYuvOptionsL(TRgbRange aRange, const TYuvFormat& aOutputFormat)
1.149 + {
1.150 + // check against test data
1.151 + if ((aRange != KTestRgbRange2) || !CompareYuvFormats(aOutputFormat, KTestYuvFormat2) )
1.152 + User::Leave(KErrCorrupt);
1.153 + }
1.154 +
1.155 +void CMMFTestVideoPreProcHwDevice::SetYuvToYuvOptionsL(const TYuvFormat& aInputFormat, const TYuvFormat& aOutputFormat)
1.156 + {
1.157 + if (!CompareYuvFormats(aInputFormat, KTestYuvFormat2) || !CompareYuvFormats(aOutputFormat, KTestYuvFormat1) )
1.158 + User::Leave(KErrCorrupt);
1.159 + }
1.160 +
1.161 +void CMMFTestVideoPreProcHwDevice::SetRotateOptionsL(TRotationType aRotationType)
1.162 + {
1.163 + if (!(aRotationType == KTestRotate2))
1.164 + User::Leave(KErrCorrupt);
1.165 + }
1.166 +
1.167 +void CMMFTestVideoPreProcHwDevice::SetScaleOptionsL(const TSize& aTargetSize, TBool aAntiAliasFiltering)
1.168 + {
1.169 + TSize testScale(KTestScaleY, KTestScaleX);
1.170 + if (!(aTargetSize == testScale) || !aAntiAliasFiltering)
1.171 + User::Leave(KErrCorrupt);
1.172 + }
1.173 +
1.174 +void CMMFTestVideoPreProcHwDevice::SetInputCropOptionsL(const TRect& aRect)
1.175 + {
1.176 + TRect testRect(KTestInputCropRectD, KTestInputCropRectC, KTestInputCropRectB, KTestInputCropRectA);
1.177 + if (!(aRect == testRect))
1.178 + User::Leave(KErrCorrupt);
1.179 + }
1.180 +
1.181 +void CMMFTestVideoPreProcHwDevice::SetOutputCropOptionsL(const TRect& aRect)
1.182 + {
1.183 + TRect testRect(KTestOutputCropRectD, KTestOutputCropRectC, KTestOutputCropRectB, KTestOutputCropRectA);
1.184 + if (!(aRect == testRect))
1.185 + User::Leave(KErrCorrupt);
1.186 + }
1.187 +
1.188 +void CMMFTestVideoPreProcHwDevice::SetOutputPadOptionsL(const TSize& aOutputSize, const TPoint& aPicturePos)
1.189 + {
1.190 + TSize testPad(KTestPadY, KTestPadX);
1.191 + TPoint testPoint(KTestPadPointY, KTestPadPointX);
1.192 +
1.193 + if (!(testPad == aOutputSize) || !(testPoint == aPicturePos))
1.194 + User::Leave(KErrCorrupt);
1.195 + }
1.196 +
1.197 +void CMMFTestVideoPreProcHwDevice::SetColorEnhancementOptionsL(const TColorEnhancementOptions& aOptions)
1.198 + {
1.199 + if (!CompareColorEnhancements(aOptions, KTestColorEnhance2))
1.200 + User::Leave(KErrCorrupt);
1.201 + }
1.202 +
1.203 +void CMMFTestVideoPreProcHwDevice::SetFrameStabilisationOptionsL(const TSize& aOutputSize, TBool aFrameStabilisation)
1.204 + {
1.205 + TSize testSize(KTestScaleY, KTestScaleX);
1.206 + if (!(aOutputSize == testSize) || !aFrameStabilisation)
1.207 + User::Leave(KErrCorrupt);
1.208 + }
1.209 +
1.210 +void CMMFTestVideoPreProcHwDevice::SetCustomPreProcessOptionsL(const TDesC8& aOptions)
1.211 + {
1.212 + if (!(aOptions == KTestCustomPreProc2))
1.213 + User::Leave(KErrCorrupt);
1.214 + }
1.215 +
1.216 +void CMMFTestVideoPreProcHwDevice::Initialize()
1.217 + {
1.218 + iProxy->MdvrpInitializeComplete(this, KErrNone);
1.219 + }
1.220 +
1.221 +void CMMFTestVideoPreProcHwDevice::WritePictureL(TVideoPicture* aPicture)
1.222 + {
1.223 + iProxy->MdvrpReturnPicture(aPicture);
1.224 + }
1.225 +
1.226 +void CMMFTestVideoPreProcHwDevice::InputEnd()
1.227 + {
1.228 + iProxy->MdvrpStreamEnd();
1.229 + }
1.230 +
1.231 +void CMMFTestVideoPreProcHwDevice::Start()
1.232 + {
1.233 + iRecPosition = KTestRecTimeStartPre;
1.234 + iIsRecording = ETrue;
1.235 + }
1.236 +
1.237 +void CMMFTestVideoPreProcHwDevice::Stop()
1.238 + {
1.239 + iRecPosition = KTestRecTimeStop;
1.240 + iIsRecording = EFalse;
1.241 + }
1.242 +
1.243 +void CMMFTestVideoPreProcHwDevice::Pause()
1.244 + {
1.245 + iRecPosition = KTestRecTimePausePre;
1.246 + iIsRecording = EFalse;
1.247 + }
1.248 +
1.249 +void CMMFTestVideoPreProcHwDevice::Resume()
1.250 + {
1.251 + iRecPosition = KTestRecTimeResumePre;
1.252 + iIsRecording = ETrue;
1.253 + }
1.254 +
1.255 +void CMMFTestVideoPreProcHwDevice::Freeze()
1.256 + {
1.257 + }
1.258 +
1.259 +void CMMFTestVideoPreProcHwDevice::ReleaseFreeze()
1.260 + {
1.261 + }
1.262 +
1.263 +TTimeIntervalMicroSeconds CMMFTestVideoPreProcHwDevice::RecordingPosition()
1.264 + {
1.265 + return iRecPosition;
1.266 + }
1.267 +
1.268 +void CMMFTestVideoPreProcHwDevice::GetPictureCounters(CMMFDevVideoRecord::TPictureCounters& aCounters)
1.269 + {
1.270 + aCounters = GetTestEncPictureCounters();
1.271 + }
1.272 +
1.273 +void CMMFTestVideoPreProcHwDevice::GetFrameStabilisationOutput(TRect& aRect)
1.274 + {
1.275 + aRect = TRect(KTestFrameStableY1, KTestFrameStableX1, KTestFrameStableY2, KTestFrameStableX2);
1.276 + }
1.277 +
1.278 +TUint CMMFTestVideoPreProcHwDevice::NumComplexityLevels()
1.279 + {
1.280 + return KTestNumComplexityLevels2;
1.281 + }
1.282 +
1.283 +void CMMFTestVideoPreProcHwDevice::SetComplexityLevel(TUint aLevel)
1.284 + {
1.285 + __ASSERT_ALWAYS(aLevel == KTestComplexityLevel2, DevVideoPreProcPanic(EPreProcPanicComplexityLevel));
1.286 + }
1.287 +
1.288 +void CMMFTestVideoPreProcHwDevice::SetOutputFormatL(const TUncompressedVideoFormat& aFormat)
1.289 + {
1.290 + if (!(aFormat == KTestVidFormat2))
1.291 + {
1.292 + User::Leave(KErrCorrupt);
1.293 + }
1.294 + }
1.295 +
1.296 +void CMMFTestVideoPreProcHwDevice::SetOutputDevice(CMMFVideoEncodeHwDevice* /*aDevice*/)
1.297 + {
1.298 + }
1.299 +
1.300 +void CMMFTestVideoPreProcHwDevice::ReturnPicture(TVideoPicture* /*aPicture*/)
1.301 + {
1.302 + }
1.303 +
1.304 +void CMMFTestVideoPreProcHwDevice::CommitL()
1.305 + {
1.306 + }
1.307 +
1.308 +void CMMFTestVideoPreProcHwDevice::Revert()
1.309 + {
1.310 + }
1.311 +
1.312 +void CMMFTestVideoPreProcHwDevice::SetProxy(MMMFDevVideoRecordProxy& aProxy)
1.313 + {
1.314 + ASSERT(iProxy == NULL);
1.315 + iProxy = &aProxy;
1.316 + }
1.317 +