1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevVideo/src/TestDevVideoPlugins/postproc.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,482 @@
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 "postproc.h"
1.20 +#include "../TestDevVideoPlayTestData.h"
1.21 +
1.22 +_LIT(KDevVideoPostProcPanicCategory, "DevVideoPostProcessor");
1.23 +void DevVideoPostProcPanic(TInt aReason)
1.24 + {
1.25 + User::Panic(KDevVideoPostProcPanicCategory, aReason);
1.26 + }
1.27 +
1.28 +CMMFVideoPostProcHwDevice* CMMFTestVideoPostProcHwDevice::NewL(TAny* /*aInitParams*/)
1.29 + {
1.30 + CMMFTestVideoPostProcHwDevice* s = new(ELeave) CMMFTestVideoPostProcHwDevice;
1.31 + return (STATIC_CAST(CMMFVideoPostProcHwDevice*, s));
1.32 + }
1.33 +
1.34 +CMMFTestVideoPostProcHwDevice::CMMFTestVideoPostProcHwDevice()
1.35 + {
1.36 + }
1.37 +
1.38 +CMMFTestVideoPostProcHwDevice::~CMMFTestVideoPostProcHwDevice()
1.39 + {
1.40 + iVideoPictures.Close();
1.41 +
1.42 + iVidFormats.Reset();
1.43 + iVidFormats.Close();
1.44 +
1.45 + iScaleFactors.Reset();
1.46 + iScaleFactors.Close();
1.47 +
1.48 + iCombinations.Reset();
1.49 + iCombinations.Close();
1.50 + }
1.51 +
1.52 +TAny* CMMFTestVideoPostProcHwDevice::CustomInterface(TUid aInterface)
1.53 + {
1.54 + if (aInterface == KUidCustomInterfaceTwo)
1.55 + {
1.56 + return this;//just want to return something non-null!
1.57 + }
1.58 + else
1.59 + {
1.60 + return NULL;
1.61 + }
1.62 + }
1.63 +
1.64 +CPostProcessorInfo* CMMFTestVideoPostProcHwDevice::PostProcessorInfoLC()
1.65 + {
1.66 + // construct array of test types
1.67 + for (TUint i = 0; i < KTestPostProcInfoCount; i++)
1.68 + {
1.69 + // append the video formats
1.70 + TUncompressedVideoFormat vid = KTestPostProcInfoFormatArray[i];
1.71 + User::LeaveIfError(iVidFormats.Append(vid));
1.72 +
1.73 + // append the combinations
1.74 + TUint32 comb = KTestPostProcInfoCombsArray[i];
1.75 + User::LeaveIfError(iCombinations.Append(comb));
1.76 +
1.77 + // append the scale factors
1.78 + TScaleFactor scale = KTestPostProcInfoScaleFactorsArray[i];
1.79 + User::LeaveIfError(iScaleFactors.Append(scale));
1.80 + }
1.81 +
1.82 + // construct the video decoder info object
1.83 + CPostProcessorInfo* vInfo = CPostProcessorInfo::NewL(
1.84 + KUidDevVideoTestPostProcHwDevice,
1.85 + KTestPostProcInfoManufacturer,
1.86 + KTestPostProcInfoIdentifier,
1.87 + TVersion(KTestPostProcInfoVersionMaj, KTestPostProcInfoVersionMin, KTestPostProcInfoVersionBuild),
1.88 + iVidFormats.Array(),
1.89 + iCombinations.Array(),
1.90 + ETrue, // accelerated
1.91 + ETrue, // supports direct display
1.92 + KTestPostProcInfoYuvToRgbCaps,
1.93 + KTestPostProcInfoRotations,
1.94 + ETrue, // scaling
1.95 + iScaleFactors.Array(),
1.96 + ETrue, // anti-aliasing
1.97 + KTestPostProcInfoISInfo );
1.98 + CleanupStack::PushL(vInfo);
1.99 +#ifdef SYMBIAN_ENABLE_MMF_MULTISCREEN_SUPPORT
1.100 + vInfo->AddSupportedScreenL(KPostProcDefaultScreenNumber);
1.101 + vInfo->AddSupportedScreenL(KPostProcSecondaryScreenNumber);
1.102 +#endif
1.103 + vInfo->SetSupportsContentProtected(ETrue);
1.104 + return vInfo;
1.105 + }
1.106 +
1.107 +void CMMFTestVideoPostProcHwDevice::GetOutputFormatListL(RArray<TUncompressedVideoFormat>& aFormats)
1.108 + {
1.109 + // append in order 3, 2, 1
1.110 + User::LeaveIfError(aFormats.Append(KTestVidFormat3));
1.111 + User::LeaveIfError(aFormats.Append(KTestVidFormat2));
1.112 + User::LeaveIfError(aFormats.Append(KTestVidFormat1));
1.113 + }
1.114 +
1.115 +void CMMFTestVideoPostProcHwDevice::SetOutputFormatL(const TUncompressedVideoFormat &aFormat)
1.116 + {
1.117 + if (!(aFormat == KTestVidFormat2))
1.118 + User::Leave(KErrCorrupt);
1.119 + }
1.120 +
1.121 +void CMMFTestVideoPostProcHwDevice::SetPostProcessTypesL(TUint32 aPostProcCombination)
1.122 + {
1.123 + if (!(aPostProcCombination == KTestProcessType2))
1.124 + User::Leave(KErrCorrupt);
1.125 + }
1.126 +
1.127 +void CMMFTestVideoPostProcHwDevice::SetInputCropOptionsL(const TRect& aRect)
1.128 + {
1.129 + TRect testRect(KTestInputCropRectD, KTestInputCropRectC, KTestInputCropRectB, KTestInputCropRectA);
1.130 + if (!(aRect == testRect))
1.131 + User::Leave(KErrCorrupt);
1.132 + }
1.133 +
1.134 +void CMMFTestVideoPostProcHwDevice::SetYuvToRgbOptionsL(const TYuvToRgbOptions& aOptions, const TYuvFormat& aYuvFormat, TRgbFormat aRgbFormat)
1.135 + {
1.136 + // check options first
1.137 + if (!CompareYuvRgbOptions(aOptions, KTestYuvToRgb2))
1.138 + User::Leave(KErrCorrupt);
1.139 +
1.140 + // now check formats
1.141 + if ( !(CompareYuvFormats(aYuvFormat, KTestYuvFormat2)) ||
1.142 + !(aRgbFormat == KTestRgbFormat2) )
1.143 + User::Leave(KErrCorrupt);
1.144 + }
1.145 +
1.146 +void CMMFTestVideoPostProcHwDevice::SetYuvToRgbOptionsL(const TYuvToRgbOptions& aOptions)
1.147 + {
1.148 + if (!CompareYuvRgbOptions(aOptions, KTestYuvToRgb2))
1.149 + User::Leave(KErrCorrupt);
1.150 + }
1.151 +
1.152 +void CMMFTestVideoPostProcHwDevice::SetRotateOptionsL(TRotationType aRotationType)
1.153 + {
1.154 + if (!(aRotationType == KTestRotate2))
1.155 + User::Leave(KErrCorrupt);
1.156 + }
1.157 +
1.158 +void CMMFTestVideoPostProcHwDevice::SetScaleOptionsL(const TSize& aTargetSize, TBool aAntiAliasFiltering)
1.159 + {
1.160 + TSize testScale(KTestScaleY, KTestScaleX);
1.161 + if (!(aTargetSize == testScale) || !aAntiAliasFiltering)
1.162 + User::Leave(KErrCorrupt);
1.163 + }
1.164 +
1.165 +void CMMFTestVideoPostProcHwDevice::SetOutputCropOptionsL(const TRect& aRect)
1.166 + {
1.167 + TRect testRect(KTestOutputCropRectD, KTestOutputCropRectC, KTestOutputCropRectB, KTestOutputCropRectA);
1.168 + if (!(aRect == testRect))
1.169 + User::Leave(KErrCorrupt);
1.170 + }
1.171 +
1.172 +void CMMFTestVideoPostProcHwDevice::SetPostProcSpecificOptionsL(const TDesC8& aOptions)
1.173 + {
1.174 + if (!(aOptions == KTestPostProcOptions2))
1.175 + User::Leave(KErrCorrupt);
1.176 + }
1.177 +
1.178 +void CMMFTestVideoPostProcHwDevice::SetClockSource(MMMFClockSource* aClock)
1.179 + {
1.180 + __ASSERT_ALWAYS(aClock, DevVideoPostProcPanic(EPostProcPanicClockSource));
1.181 +
1.182 + // call Time() to check that clock can be used
1.183 + TTimeIntervalMicroSeconds currTime(0); // done this way to remove compiler warning
1.184 + currTime = aClock->Time();
1.185 + }
1.186 +
1.187 +void CMMFTestVideoPostProcHwDevice::SetVideoDestScreenL(TBool aScreen)
1.188 + {
1.189 + if (aScreen)
1.190 + {
1.191 + // Must be normal devvideo test. Leave with special number to show we got the
1.192 + // value through ok
1.193 + User::Leave(KErrHardwareNotAvailable);
1.194 + }
1.195 + else
1.196 + {
1.197 + // Special test plugin feature: we're being told to start outputing
1.198 + // video pictures up to DevVideo.
1.199 + // Create 10 video pictures
1.200 + iVideoPictures.Reset();
1.201 + for (TInt i=0; i<10; i++)
1.202 + {
1.203 + // Create a video picture that only has a valid timestamp
1.204 + TVideoPicture picture;
1.205 + picture.iTimestamp = TTimeIntervalMicroSeconds(i);
1.206 + picture.iOptions = TVideoPicture::ETimestamp;
1.207 + User::LeaveIfError(iVideoPictures.Append(picture));
1.208 + }
1.209 + }
1.210 + }
1.211 +
1.212 +void CMMFTestVideoPostProcHwDevice::Initialize()
1.213 + {
1.214 + iProxy->MdvppInitializeComplete(this, KErrNone);
1.215 + }
1.216 +
1.217 +void CMMFTestVideoPostProcHwDevice::StartDirectScreenAccessL(const TRect& aVideoRect, CFbsScreenDevice& /*aScreenDevice*/, const TRegion& aClipRegion)
1.218 + {
1.219 + TRect dsaRect(KTestDSARectA, KTestDSARectB, KTestDSARectC, KTestDSARectD);
1.220 + TRegionFix<1> dsaReg(dsaRect);
1.221 +
1.222 + // probably no need to check aScreenDevice
1.223 + if ( /*!(&aScreenDevice) || */!(dsaRect == aVideoRect) ||
1.224 + !(dsaReg.BoundingRect() == aClipRegion.BoundingRect()) )
1.225 + User::Leave(KErrNotSupported);
1.226 +
1.227 + }
1.228 +
1.229 +void CMMFTestVideoPostProcHwDevice::SetScreenClipRegion(const TRegion& aRegion)
1.230 + {
1.231 + TRect dsaRect(KTestDSARectA, KTestDSARectB, KTestDSARectC, KTestDSARectD);
1.232 + TRegionFix<1> dsaReg(dsaRect);
1.233 +
1.234 + __ASSERT_ALWAYS(dsaReg.BoundingRect() == aRegion.BoundingRect(),
1.235 + DevVideoPostProcPanic(EPostProcPanicScreenClipRegion));
1.236 + }
1.237 +
1.238 +void CMMFTestVideoPostProcHwDevice::SetPauseOnClipFail(TBool aPause)
1.239 + {
1.240 + __ASSERT_ALWAYS(aPause, DevVideoPostProcPanic(EPostProcPanicPauseClipFail));
1.241 + }
1.242 +
1.243 +void CMMFTestVideoPostProcHwDevice::AbortDirectScreenAccess()
1.244 + {
1.245 + // do nothing - there is no way to check this
1.246 + }
1.247 +
1.248 +TBool CMMFTestVideoPostProcHwDevice::IsPlaying()
1.249 + {
1.250 + return iIsPlaying;
1.251 + }
1.252 +
1.253 +void CMMFTestVideoPostProcHwDevice::Redraw()
1.254 + {
1.255 + // do nothing - there is no way to check this
1.256 + }
1.257 +
1.258 +void CMMFTestVideoPostProcHwDevice::Start()
1.259 + {
1.260 + // set iIsPlaying flag
1.261 + iIsPlaying = ETrue;
1.262 +
1.263 + // if we're doing the picture tests, start sending pictures to DevVideo
1.264 + if (iVideoPictures.Count() > 0)
1.265 + {
1.266 + iProxy->MdvppNewPicture(&(iVideoPictures[0]));
1.267 + }
1.268 + }
1.269 +
1.270 +void CMMFTestVideoPostProcHwDevice::Stop()
1.271 + {
1.272 + iIsPlaying = EFalse;
1.273 + }
1.274 +
1.275 +void CMMFTestVideoPostProcHwDevice::Pause()
1.276 + {
1.277 + iIsPlaying = EFalse;
1.278 + }
1.279 +
1.280 +void CMMFTestVideoPostProcHwDevice::Resume()
1.281 + {
1.282 + iIsPlaying = ETrue;
1.283 + }
1.284 +
1.285 +void CMMFTestVideoPostProcHwDevice::SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition)
1.286 + {
1.287 + if (aPlaybackPosition == TTimeIntervalMicroSeconds(KTestPositionFatal))
1.288 + {
1.289 + iProxy->MdvppFatalError(this, KErrDied);
1.290 + }
1.291 + else
1.292 + {
1.293 + __ASSERT_ALWAYS(aPlaybackPosition == TTimeIntervalMicroSeconds(KTestPosition), DevVideoPostProcPanic(EPostProcPanicSetPosition));
1.294 + }
1.295 + }
1.296 +
1.297 +void CMMFTestVideoPostProcHwDevice::FreezePicture(const TTimeIntervalMicroSeconds& aTimestamp)
1.298 + {
1.299 + __ASSERT_ALWAYS(aTimestamp == TTimeIntervalMicroSeconds(KTestPosition), DevVideoPostProcPanic(EPostProcPanicFreezePicture));
1.300 + }
1.301 +
1.302 +void CMMFTestVideoPostProcHwDevice::ReleaseFreeze(const TTimeIntervalMicroSeconds& aTimestamp)
1.303 + {
1.304 + __ASSERT_ALWAYS(aTimestamp == TTimeIntervalMicroSeconds(KTestPosition), DevVideoPostProcPanic(EPostProcPanicReleaseFreeze));
1.305 + }
1.306 +
1.307 +TTimeIntervalMicroSeconds CMMFTestVideoPostProcHwDevice::PlaybackPosition()
1.308 + {
1.309 + return TTimeIntervalMicroSeconds(KTestPlayPosition);
1.310 + }
1.311 +
1.312 +TUint CMMFTestVideoPostProcHwDevice::PictureBufferBytes()
1.313 + {
1.314 + return KTestPictureBytes;
1.315 + }
1.316 +
1.317 +void CMMFTestVideoPostProcHwDevice::GetPictureCounters(CMMFDevVideoPlay::TPictureCounters& aCounters)
1.318 + {
1.319 + aCounters = GetTestPictureCounters();
1.320 + }
1.321 +
1.322 +void CMMFTestVideoPostProcHwDevice::SetComplexityLevel(TUint aLevel)
1.323 + {
1.324 + __ASSERT_ALWAYS(aLevel == KTestComplexityLevel2, DevVideoPostProcPanic(EPostProcPanicComplexityLevel));
1.325 + }
1.326 +
1.327 +TUint CMMFTestVideoPostProcHwDevice::NumComplexityLevels()
1.328 + {
1.329 + return KTestNumComplexityLevels2;
1.330 + }
1.331 +
1.332 +void CMMFTestVideoPostProcHwDevice::GetComplexityLevelInfo(TUint aLevel, CMMFDevVideoPlay::TComplexityLevelInfo& aInfo)
1.333 + {
1.334 + __ASSERT_ALWAYS(aLevel == KTestComplexityLevel2, DevVideoPostProcPanic(EPostProcPanicComplexityLevelInfo));
1.335 +
1.336 + aInfo = GetTestLevelInfo(aLevel);;
1.337 + }
1.338 +
1.339 +void CMMFTestVideoPostProcHwDevice::ReturnPicture(TVideoPicture* /*aPicture*/)
1.340 + {
1.341 + switch (iCurrentPicture)
1.342 + {
1.343 + case 0:
1.344 + // Send two more pictures
1.345 + iCurrentPicture = 1;
1.346 + iProxy->MdvppNewPicture(&(iVideoPictures[1]));
1.347 + iCurrentPicture = 2;
1.348 + iProxy->MdvppNewPicture(&(iVideoPictures[2]));
1.349 + break;
1.350 + case 2:
1.351 + // Send three more pictures
1.352 + iCurrentPicture = 3;
1.353 + iProxy->MdvppNewPicture(&(iVideoPictures[3]));
1.354 + iCurrentPicture = 4;
1.355 + iProxy->MdvppNewPicture(&(iVideoPictures[4]));
1.356 + iCurrentPicture = 5;
1.357 + iProxy->MdvppNewPicture(&(iVideoPictures[5]));
1.358 + break;
1.359 + case 5:
1.360 + // Send the rest of the pictures
1.361 + iCurrentPicture = 6;
1.362 + iProxy->MdvppNewPicture(&(iVideoPictures[6]));
1.363 + iCurrentPicture = 7;
1.364 + iProxy->MdvppNewPicture(&(iVideoPictures[7]));
1.365 + iCurrentPicture = 8;
1.366 + iProxy->MdvppNewPicture(&(iVideoPictures[8]));
1.367 + iCurrentPicture = 9;
1.368 + iProxy->MdvppNewPicture(&(iVideoPictures[9]));
1.369 + break;
1.370 + default:
1.371 + break;
1.372 + };
1.373 + }
1.374 +
1.375 +TBool CMMFTestVideoPostProcHwDevice::GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& aFormat)
1.376 + {
1.377 + TBool ret = EFalse;
1.378 +
1.379 + if (aFormat.iDataFormat == EYuvRawData)
1.380 + {
1.381 + if (CompareYuvFormats(aFormat.iYuvFormat, KTestYuvFormat1))
1.382 + {
1.383 + ret = ETrue;
1.384 + aPictureData.iDataFormat = EYuvRawData;
1.385 + aPictureData.iDataSize = TSize(KTestPictureDataSizeX, KTestPictureDataSizeY);
1.386 + aPictureData.iRawData = NULL;
1.387 + }
1.388 + }
1.389 +
1.390 + return ret;
1.391 + }
1.392 +
1.393 +void CMMFTestVideoPostProcHwDevice::GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat, const TTimeIntervalMicroSeconds& aPresentationTimestamp)
1.394 + {
1.395 + if ((aFormat.iDataFormat == EYuvRawData) && (aPresentationTimestamp == TTimeIntervalMicroSeconds(KTestSnapshotTimestamp)) )
1.396 + {
1.397 + if (CompareYuvFormats(aFormat.iYuvFormat, KTestYuvFormat1))
1.398 + {
1.399 + aPictureData->iDataFormat = EYuvRawData;
1.400 + aPictureData->iDataSize = TSize(KTestPictureDataSizeX, KTestPictureDataSizeY);
1.401 + aPictureData->iRawData = NULL;
1.402 +
1.403 + // call the snapshot callback
1.404 + iProxy->MdvppTimedSnapshotComplete(KErrNone, aPictureData, aPresentationTimestamp, iPictureId);
1.405 + }
1.406 + }
1.407 + else
1.408 + {
1.409 + User::Leave(KErrCorrupt);
1.410 + }
1.411 + }
1.412 +
1.413 +void CMMFTestVideoPostProcHwDevice::GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat, const TPictureId& aPictureId)
1.414 + {
1.415 + if ((aFormat.iDataFormat == EYuvRawData) &&
1.416 + (aPictureId.iIdType == KTestSnapshotId.iIdType) &&
1.417 + (aPictureId.iId == KTestSnapshotId.iId) )
1.418 + {
1.419 + if (CompareYuvFormats(aFormat.iYuvFormat, KTestYuvFormat1))
1.420 + {
1.421 + aPictureData->iDataFormat = EYuvRawData;
1.422 + aPictureData->iDataSize = TSize(KTestPictureDataSizeX, KTestPictureDataSizeY);
1.423 + aPictureData->iRawData = NULL;
1.424 +
1.425 + iPictureTimestamp = 0;
1.426 +
1.427 + // call the snapshot callback
1.428 + iProxy->MdvppTimedSnapshotComplete(KErrNone, aPictureData, iPictureTimestamp, aPictureId);
1.429 + }
1.430 + }
1.431 + else
1.432 + {
1.433 + User::Leave(KErrCorrupt);
1.434 + }
1.435 + }
1.436 +
1.437 +void CMMFTestVideoPostProcHwDevice::CancelTimedSnapshot()
1.438 + {
1.439 + // call the snapshot callback with error
1.440 + iProxy->MdvppTimedSnapshotComplete(KErrAbort, &iPictureData, iPictureTimestamp, iPictureId);
1.441 + }
1.442 +
1.443 +void CMMFTestVideoPostProcHwDevice::GetSupportedSnapshotFormatsL(RArray<TUncompressedVideoFormat>& aFormats)
1.444 + {
1.445 + // append in order 3, 2, 1
1.446 + User::LeaveIfError(aFormats.Append(KTestVidFormat1));
1.447 + User::LeaveIfError(aFormats.Append(KTestVidFormat2));
1.448 + User::LeaveIfError(aFormats.Append(KTestVidFormat3));
1.449 + }
1.450 +
1.451 +void CMMFTestVideoPostProcHwDevice::InputEnd()
1.452 + {
1.453 + iProxy->MdvppStreamEnd();
1.454 + }
1.455 +
1.456 +void CMMFTestVideoPostProcHwDevice::SetInputFormatL(const TUncompressedVideoFormat& aFormat)
1.457 + {
1.458 + if (!(aFormat == KTestVidFormat2))
1.459 + {
1.460 + User::Leave(KErrCorrupt);
1.461 + }
1.462 + }
1.463 +
1.464 +void CMMFTestVideoPostProcHwDevice::SetInputDevice(CMMFVideoDecodeHwDevice* /*aDevice*/)
1.465 + {
1.466 + }
1.467 +
1.468 +void CMMFTestVideoPostProcHwDevice::WritePictureL(TVideoPicture* aPicture)
1.469 + {
1.470 + iProxy->MdvppReturnPicture(aPicture);
1.471 + }
1.472 +
1.473 +void CMMFTestVideoPostProcHwDevice::CommitL()
1.474 + {
1.475 + }
1.476 +
1.477 +void CMMFTestVideoPostProcHwDevice::Revert()
1.478 + {
1.479 + }
1.480 +
1.481 +void CMMFTestVideoPostProcHwDevice::SetProxy(MMMFDevVideoPlayProxy& aProxy)
1.482 + {
1.483 + iProxy = &aProxy;
1.484 + }
1.485 +