os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevVideo/src/TestDevVideoPlugins/postproc.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 "postproc.h"
    17 #include "../TestDevVideoPlayTestData.h"
    18 
    19 _LIT(KDevVideoPostProcPanicCategory, "DevVideoPostProcessor");
    20 void DevVideoPostProcPanic(TInt aReason)
    21 	{
    22 	User::Panic(KDevVideoPostProcPanicCategory, aReason);
    23 	}
    24 
    25 CMMFVideoPostProcHwDevice* CMMFTestVideoPostProcHwDevice::NewL(TAny* /*aInitParams*/)
    26 	{
    27 	CMMFTestVideoPostProcHwDevice* s = new(ELeave) CMMFTestVideoPostProcHwDevice;
    28 	return (STATIC_CAST(CMMFVideoPostProcHwDevice*, s));
    29 	}
    30 
    31 CMMFTestVideoPostProcHwDevice::CMMFTestVideoPostProcHwDevice()
    32 	{
    33 	}
    34 
    35 CMMFTestVideoPostProcHwDevice::~CMMFTestVideoPostProcHwDevice()
    36 	{
    37 	iVideoPictures.Close();
    38 	
    39 	iVidFormats.Reset();
    40 	iVidFormats.Close();
    41 
    42 	iScaleFactors.Reset();
    43 	iScaleFactors.Close();
    44 
    45 	iCombinations.Reset();
    46 	iCombinations.Close();
    47 	}
    48 
    49 TAny* CMMFTestVideoPostProcHwDevice::CustomInterface(TUid aInterface)
    50 	{
    51 	if (aInterface == KUidCustomInterfaceTwo)
    52 		{
    53 		return this;//just want to return something non-null!
    54 		}
    55 	else
    56 		{
    57 		return NULL;
    58 		}
    59 	}
    60 
    61 CPostProcessorInfo* CMMFTestVideoPostProcHwDevice::PostProcessorInfoLC()
    62 	{
    63 	// construct array of test types
    64 	for (TUint i = 0; i < KTestPostProcInfoCount; i++)
    65 		{
    66 		// append the video formats
    67 		TUncompressedVideoFormat vid = KTestPostProcInfoFormatArray[i];
    68 		User::LeaveIfError(iVidFormats.Append(vid));
    69 
    70 		// append the combinations
    71 		TUint32 comb = KTestPostProcInfoCombsArray[i];
    72 		User::LeaveIfError(iCombinations.Append(comb));
    73 
    74 		// append the scale factors
    75 		TScaleFactor scale = KTestPostProcInfoScaleFactorsArray[i];
    76 		User::LeaveIfError(iScaleFactors.Append(scale));
    77 		}
    78 	
    79 	// construct the video decoder info object
    80 	CPostProcessorInfo* vInfo = CPostProcessorInfo::NewL(
    81 		KUidDevVideoTestPostProcHwDevice,
    82 		KTestPostProcInfoManufacturer,
    83 		KTestPostProcInfoIdentifier,
    84 		TVersion(KTestPostProcInfoVersionMaj, KTestPostProcInfoVersionMin, KTestPostProcInfoVersionBuild),
    85 		iVidFormats.Array(),
    86 		iCombinations.Array(),
    87 		ETrue,	// accelerated
    88 		ETrue,	// supports direct display
    89 		KTestPostProcInfoYuvToRgbCaps,
    90 		KTestPostProcInfoRotations,
    91 		ETrue,	// scaling
    92 		iScaleFactors.Array(),
    93 		ETrue,	// anti-aliasing
    94 		KTestPostProcInfoISInfo );
    95 	CleanupStack::PushL(vInfo);
    96 #ifdef SYMBIAN_ENABLE_MMF_MULTISCREEN_SUPPORT
    97 	vInfo->AddSupportedScreenL(KPostProcDefaultScreenNumber);
    98 	vInfo->AddSupportedScreenL(KPostProcSecondaryScreenNumber);
    99 #endif
   100 	vInfo->SetSupportsContentProtected(ETrue);
   101 	return vInfo;
   102 	}
   103 
   104 void CMMFTestVideoPostProcHwDevice::GetOutputFormatListL(RArray<TUncompressedVideoFormat>& aFormats)
   105 	{
   106 	// append in order 3, 2, 1
   107 	User::LeaveIfError(aFormats.Append(KTestVidFormat3));
   108 	User::LeaveIfError(aFormats.Append(KTestVidFormat2));
   109 	User::LeaveIfError(aFormats.Append(KTestVidFormat1));
   110 	}
   111 
   112 void CMMFTestVideoPostProcHwDevice::SetOutputFormatL(const TUncompressedVideoFormat &aFormat)
   113 	{
   114 	if (!(aFormat == KTestVidFormat2))
   115 		User::Leave(KErrCorrupt);
   116 	}
   117 
   118 void CMMFTestVideoPostProcHwDevice::SetPostProcessTypesL(TUint32 aPostProcCombination)
   119 	{
   120 	if (!(aPostProcCombination == KTestProcessType2))
   121 		User::Leave(KErrCorrupt);
   122 	}
   123 
   124 void CMMFTestVideoPostProcHwDevice::SetInputCropOptionsL(const TRect& aRect)
   125 	{
   126 	TRect testRect(KTestInputCropRectD, KTestInputCropRectC, KTestInputCropRectB, KTestInputCropRectA);
   127 	if (!(aRect == testRect))
   128 		User::Leave(KErrCorrupt);
   129 	}
   130 
   131 void CMMFTestVideoPostProcHwDevice::SetYuvToRgbOptionsL(const TYuvToRgbOptions& aOptions, const TYuvFormat& aYuvFormat, TRgbFormat aRgbFormat)
   132 	{
   133 	// check options first
   134 	if (!CompareYuvRgbOptions(aOptions, KTestYuvToRgb2))
   135 		User::Leave(KErrCorrupt);
   136 
   137 	// now check formats
   138 	if ( !(CompareYuvFormats(aYuvFormat, KTestYuvFormat2)) || 
   139 		 !(aRgbFormat == KTestRgbFormat2) )
   140 		User::Leave(KErrCorrupt);
   141 	}
   142 
   143 void CMMFTestVideoPostProcHwDevice::SetYuvToRgbOptionsL(const TYuvToRgbOptions& aOptions)
   144 	{
   145 	if (!CompareYuvRgbOptions(aOptions, KTestYuvToRgb2))
   146 		User::Leave(KErrCorrupt);
   147 	}
   148 
   149 void CMMFTestVideoPostProcHwDevice::SetRotateOptionsL(TRotationType aRotationType)
   150 	{
   151 	if (!(aRotationType == KTestRotate2))
   152 		User::Leave(KErrCorrupt);
   153 	}
   154 
   155 void CMMFTestVideoPostProcHwDevice::SetScaleOptionsL(const TSize& aTargetSize, TBool aAntiAliasFiltering)
   156 	{
   157 	TSize testScale(KTestScaleY, KTestScaleX);
   158 	if (!(aTargetSize == testScale) || !aAntiAliasFiltering)
   159 		User::Leave(KErrCorrupt);
   160 	}
   161 
   162 void CMMFTestVideoPostProcHwDevice::SetOutputCropOptionsL(const TRect& aRect)
   163 	{
   164 	TRect testRect(KTestOutputCropRectD, KTestOutputCropRectC, KTestOutputCropRectB, KTestOutputCropRectA);
   165 	if (!(aRect == testRect))
   166 		User::Leave(KErrCorrupt);
   167 	}
   168 
   169 void CMMFTestVideoPostProcHwDevice::SetPostProcSpecificOptionsL(const TDesC8& aOptions)
   170 	{
   171 	if (!(aOptions == KTestPostProcOptions2))
   172 		User::Leave(KErrCorrupt);
   173 	}
   174 
   175 void CMMFTestVideoPostProcHwDevice::SetClockSource(MMMFClockSource* aClock)
   176 	{
   177 	__ASSERT_ALWAYS(aClock, DevVideoPostProcPanic(EPostProcPanicClockSource)); 
   178 
   179 	// call Time() to check that clock can be used
   180 	TTimeIntervalMicroSeconds currTime(0); // done this way to remove compiler warning
   181 	currTime = aClock->Time();
   182 	}
   183 
   184 void CMMFTestVideoPostProcHwDevice::SetVideoDestScreenL(TBool aScreen)
   185 	{
   186 	if (aScreen)
   187 		{
   188 		// Must be normal devvideo test.  Leave with special number to show we got the
   189 		// value through ok
   190 		User::Leave(KErrHardwareNotAvailable);
   191 		}
   192 	else
   193 		{
   194 		// Special test plugin feature: we're being told to start outputing
   195 		// video pictures up to DevVideo.
   196 		// Create 10 video pictures
   197 		iVideoPictures.Reset();
   198 		for (TInt i=0; i<10; i++)
   199 			{
   200 			// Create a video picture that only has a valid timestamp
   201 			TVideoPicture picture;
   202 			picture.iTimestamp = TTimeIntervalMicroSeconds(i);
   203 			picture.iOptions = TVideoPicture::ETimestamp;
   204 			User::LeaveIfError(iVideoPictures.Append(picture));
   205 			}
   206 		}
   207 	}
   208 
   209 void CMMFTestVideoPostProcHwDevice::Initialize()
   210 	{
   211 	iProxy->MdvppInitializeComplete(this, KErrNone);
   212 	}
   213 
   214 void CMMFTestVideoPostProcHwDevice::StartDirectScreenAccessL(const TRect& aVideoRect, CFbsScreenDevice& /*aScreenDevice*/, const TRegion& aClipRegion)
   215 	{
   216 	TRect dsaRect(KTestDSARectA, KTestDSARectB, KTestDSARectC, KTestDSARectD);
   217 	TRegionFix<1> dsaReg(dsaRect);
   218 
   219 	// probably no need to check aScreenDevice
   220 	if ( /*!(&aScreenDevice) || */!(dsaRect == aVideoRect) || 
   221 		 !(dsaReg.BoundingRect() == aClipRegion.BoundingRect()) )
   222 		 User::Leave(KErrNotSupported);
   223 
   224 	}
   225 
   226 void CMMFTestVideoPostProcHwDevice::SetScreenClipRegion(const TRegion& aRegion)
   227 	{
   228 	TRect dsaRect(KTestDSARectA, KTestDSARectB, KTestDSARectC, KTestDSARectD);
   229 	TRegionFix<1> dsaReg(dsaRect);
   230 
   231 	__ASSERT_ALWAYS(dsaReg.BoundingRect() == aRegion.BoundingRect(), 
   232 		DevVideoPostProcPanic(EPostProcPanicScreenClipRegion)); 
   233 	}
   234 
   235 void CMMFTestVideoPostProcHwDevice::SetPauseOnClipFail(TBool aPause)
   236 	{
   237 	__ASSERT_ALWAYS(aPause, DevVideoPostProcPanic(EPostProcPanicPauseClipFail));
   238 	}
   239 
   240 void CMMFTestVideoPostProcHwDevice::AbortDirectScreenAccess()
   241 	{
   242 	// do nothing - there is no way to check this
   243 	}
   244 
   245 TBool CMMFTestVideoPostProcHwDevice::IsPlaying()
   246 	{
   247 	return iIsPlaying;
   248 	}
   249 
   250 void CMMFTestVideoPostProcHwDevice::Redraw()
   251 	{
   252 	// do nothing - there is no way to check this
   253 	}
   254 
   255 void CMMFTestVideoPostProcHwDevice::Start()
   256 	{
   257 	// set iIsPlaying flag
   258 	iIsPlaying = ETrue;
   259 
   260 	// if we're doing the picture tests, start sending pictures to DevVideo
   261 	if (iVideoPictures.Count() > 0)
   262 		{
   263 		iProxy->MdvppNewPicture(&(iVideoPictures[0]));
   264 		}
   265 	}
   266 
   267 void CMMFTestVideoPostProcHwDevice::Stop()
   268 	{
   269 	iIsPlaying = EFalse;
   270 	}
   271 
   272 void CMMFTestVideoPostProcHwDevice::Pause()
   273 	{
   274 	iIsPlaying = EFalse;
   275 	}
   276 
   277 void CMMFTestVideoPostProcHwDevice::Resume()
   278 	{
   279 	iIsPlaying = ETrue;
   280 	}
   281 
   282 void CMMFTestVideoPostProcHwDevice::SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition)
   283 	{
   284 	if (aPlaybackPosition == TTimeIntervalMicroSeconds(KTestPositionFatal))
   285 		{
   286 		iProxy->MdvppFatalError(this, KErrDied);
   287 		}
   288 	else
   289 		{
   290 		__ASSERT_ALWAYS(aPlaybackPosition == TTimeIntervalMicroSeconds(KTestPosition), DevVideoPostProcPanic(EPostProcPanicSetPosition));
   291 		}
   292 	}
   293 
   294 void CMMFTestVideoPostProcHwDevice::FreezePicture(const TTimeIntervalMicroSeconds& aTimestamp)
   295 	{
   296 	__ASSERT_ALWAYS(aTimestamp == TTimeIntervalMicroSeconds(KTestPosition), DevVideoPostProcPanic(EPostProcPanicFreezePicture));
   297 	}
   298 
   299 void CMMFTestVideoPostProcHwDevice::ReleaseFreeze(const TTimeIntervalMicroSeconds& aTimestamp)
   300 	{
   301 	__ASSERT_ALWAYS(aTimestamp == TTimeIntervalMicroSeconds(KTestPosition), DevVideoPostProcPanic(EPostProcPanicReleaseFreeze));
   302 	}
   303 
   304 TTimeIntervalMicroSeconds CMMFTestVideoPostProcHwDevice::PlaybackPosition()
   305 	{
   306 	return TTimeIntervalMicroSeconds(KTestPlayPosition);
   307 	}
   308 
   309 TUint CMMFTestVideoPostProcHwDevice::PictureBufferBytes()
   310 	{
   311 	return KTestPictureBytes;
   312 	}
   313 
   314 void CMMFTestVideoPostProcHwDevice::GetPictureCounters(CMMFDevVideoPlay::TPictureCounters& aCounters)
   315 	{
   316 	aCounters = GetTestPictureCounters();
   317 	}
   318 
   319 void CMMFTestVideoPostProcHwDevice::SetComplexityLevel(TUint aLevel)
   320 	{
   321 	__ASSERT_ALWAYS(aLevel == KTestComplexityLevel2, DevVideoPostProcPanic(EPostProcPanicComplexityLevel));
   322 	}
   323 
   324 TUint CMMFTestVideoPostProcHwDevice::NumComplexityLevels()
   325 	{
   326 	return KTestNumComplexityLevels2;
   327 	}
   328 
   329 void CMMFTestVideoPostProcHwDevice::GetComplexityLevelInfo(TUint aLevel, CMMFDevVideoPlay::TComplexityLevelInfo& aInfo)
   330 	{
   331 	__ASSERT_ALWAYS(aLevel == KTestComplexityLevel2, DevVideoPostProcPanic(EPostProcPanicComplexityLevelInfo));
   332 
   333 	aInfo = GetTestLevelInfo(aLevel);;
   334 	}
   335 
   336 void CMMFTestVideoPostProcHwDevice::ReturnPicture(TVideoPicture* /*aPicture*/)
   337 	{
   338 	switch (iCurrentPicture)
   339 		{
   340 	case 0:
   341 		// Send two more pictures
   342 		iCurrentPicture = 1;
   343 		iProxy->MdvppNewPicture(&(iVideoPictures[1]));
   344 		iCurrentPicture = 2;
   345 		iProxy->MdvppNewPicture(&(iVideoPictures[2]));
   346 		break;
   347 	case 2:
   348 		// Send three more pictures
   349 		iCurrentPicture = 3;
   350 		iProxy->MdvppNewPicture(&(iVideoPictures[3]));
   351 		iCurrentPicture = 4;
   352 		iProxy->MdvppNewPicture(&(iVideoPictures[4]));
   353 		iCurrentPicture = 5;
   354 		iProxy->MdvppNewPicture(&(iVideoPictures[5]));
   355 		break;
   356 	case 5:
   357 		// Send the rest of the pictures
   358 		iCurrentPicture = 6;
   359 		iProxy->MdvppNewPicture(&(iVideoPictures[6]));
   360 		iCurrentPicture = 7;
   361 		iProxy->MdvppNewPicture(&(iVideoPictures[7]));
   362 		iCurrentPicture = 8;
   363 		iProxy->MdvppNewPicture(&(iVideoPictures[8]));
   364 		iCurrentPicture = 9;
   365 		iProxy->MdvppNewPicture(&(iVideoPictures[9]));
   366 		break;
   367 	default:
   368 		break;
   369 		};
   370 	}
   371 
   372 TBool CMMFTestVideoPostProcHwDevice::GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& aFormat)
   373 	{
   374 	TBool ret = EFalse;
   375 
   376 	if (aFormat.iDataFormat == EYuvRawData)
   377 		{
   378 		if (CompareYuvFormats(aFormat.iYuvFormat, KTestYuvFormat1))
   379 			{
   380 			ret = ETrue;
   381 			aPictureData.iDataFormat = EYuvRawData;
   382 			aPictureData.iDataSize = TSize(KTestPictureDataSizeX, KTestPictureDataSizeY);
   383 			aPictureData.iRawData = NULL;
   384 			}
   385 		}
   386 
   387 	return ret;
   388 	}
   389 
   390 void CMMFTestVideoPostProcHwDevice::GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat, const TTimeIntervalMicroSeconds& aPresentationTimestamp)
   391 	{
   392 	if ((aFormat.iDataFormat == EYuvRawData) && (aPresentationTimestamp == TTimeIntervalMicroSeconds(KTestSnapshotTimestamp)) )
   393 		{
   394 		if (CompareYuvFormats(aFormat.iYuvFormat, KTestYuvFormat1))
   395 			{
   396 			aPictureData->iDataFormat = EYuvRawData;
   397 			aPictureData->iDataSize = TSize(KTestPictureDataSizeX, KTestPictureDataSizeY);
   398 			aPictureData->iRawData = NULL;
   399 
   400 			// call the snapshot callback
   401 			iProxy->MdvppTimedSnapshotComplete(KErrNone, aPictureData, aPresentationTimestamp, iPictureId);
   402 			}
   403 		}
   404 	else
   405 		{
   406 		User::Leave(KErrCorrupt);
   407 		}
   408 	}
   409 
   410 void CMMFTestVideoPostProcHwDevice::GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat, const TPictureId& aPictureId)
   411 	{
   412 	if ((aFormat.iDataFormat == EYuvRawData) && 
   413 		(aPictureId.iIdType == KTestSnapshotId.iIdType) &&
   414 		(aPictureId.iId == KTestSnapshotId.iId) )
   415 		{
   416 		if (CompareYuvFormats(aFormat.iYuvFormat, KTestYuvFormat1))
   417 			{
   418 			aPictureData->iDataFormat = EYuvRawData;
   419 			aPictureData->iDataSize = TSize(KTestPictureDataSizeX, KTestPictureDataSizeY);
   420 			aPictureData->iRawData = NULL;
   421 
   422 			iPictureTimestamp = 0;
   423 
   424 			// call the snapshot callback
   425 			iProxy->MdvppTimedSnapshotComplete(KErrNone, aPictureData, iPictureTimestamp, aPictureId);
   426 			}
   427 		}
   428 	else
   429 		{
   430 		User::Leave(KErrCorrupt);
   431 		}
   432 	}
   433 
   434 void CMMFTestVideoPostProcHwDevice::CancelTimedSnapshot()
   435 	{
   436 	// call the snapshot callback with error
   437 	iProxy->MdvppTimedSnapshotComplete(KErrAbort, &iPictureData, iPictureTimestamp, iPictureId);
   438 	}
   439 
   440 void CMMFTestVideoPostProcHwDevice::GetSupportedSnapshotFormatsL(RArray<TUncompressedVideoFormat>& aFormats)
   441 	{
   442 	// append in order 3, 2, 1
   443 	User::LeaveIfError(aFormats.Append(KTestVidFormat1));
   444 	User::LeaveIfError(aFormats.Append(KTestVidFormat2));
   445 	User::LeaveIfError(aFormats.Append(KTestVidFormat3));
   446 	}
   447 
   448 void CMMFTestVideoPostProcHwDevice::InputEnd()
   449 	{
   450 	iProxy->MdvppStreamEnd();
   451 	}
   452 
   453 void CMMFTestVideoPostProcHwDevice::SetInputFormatL(const TUncompressedVideoFormat& aFormat)
   454 	{
   455 	if (!(aFormat == KTestVidFormat2))
   456 		{
   457 		User::Leave(KErrCorrupt);
   458 		}
   459 	}
   460 
   461 void CMMFTestVideoPostProcHwDevice::SetInputDevice(CMMFVideoDecodeHwDevice* /*aDevice*/)
   462 	{
   463 	}
   464 
   465 void CMMFTestVideoPostProcHwDevice::WritePictureL(TVideoPicture* aPicture)
   466 	{
   467 	iProxy->MdvppReturnPicture(aPicture);
   468 	}
   469 
   470 void CMMFTestVideoPostProcHwDevice::CommitL()
   471 	{
   472 	}
   473 
   474 void CMMFTestVideoPostProcHwDevice::Revert()
   475 	{
   476 	}
   477 
   478 void CMMFTestVideoPostProcHwDevice::SetProxy(MMMFDevVideoPlayProxy& aProxy)
   479 	{
   480 	iProxy = &aProxy;
   481 	}
   482