os/mm/mmapitest/devvideohaitest/src/H264DecTestEngine.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 
    20 // INCLUDE FILES
    21 #include "H264DecTestEngine.h"
    22 #include "T_DevVideoConstants.h"
    23 
    24 #ifdef __CI_HEADERS__
    25 #include <buffermanagementci.h>  // Custom interface buffre management
    26 
    27 #endif
    28 
    29 
    30 #ifdef __SECUREOUTPUTCI__
    31 #include <secureoutputci.h>
    32 #endif
    33 
    34 #include <Devvideoplay.h>
    35 #include <Devvideobase.h>
    36 #include <Devvideoconstants.h>
    37 #include <hal.h>
    38 #include <hal_data.h>
    39 //#define __MEM_CHECK_
    40 
    41 
    42 // Ecom
    43 #include <ecom.h>
    44 
    45 
    46 /* ----------------------------------------------------------------------------
    47 * Name:       CVDecTestEngine::~CVDecTestEngine()
    48 * Purpose:    Deconstructor
    49 * Parameters: None
    50 * Return:     None
    51 * --------------------------------------------------------------------------*/
    52 
    53 CVDecTestEngine::~CVDecTestEngine ()
    54 {
    55 	delete iDecTestAO;
    56 	delete iClock;
    57 }
    58 
    59 
    60 /* ----------------------------------------------------------------------------
    61 * Name:       CVDecTestEngine:NewL()
    62 * Purpose:    Create instance of test engine
    63 * Parameters: MVDecEngineObserver& aTestClass
    64 * Return:     CVDecTestEngine*
    65 * --------------------------------------------------------------------------*/
    66 
    67 CVDecTestEngine* CVDecTestEngine::NewL(MVDecEngineObserver& aTestClass)
    68 {
    69 	CVDecTestEngine* self = new(ELeave) CVDecTestEngine;
    70 
    71 	CleanupStack::PushL( self );
    72 	self->ConstructL(aTestClass);
    73 	CleanupStack::Pop();
    74 
    75 	return self;
    76 }
    77 
    78 
    79 /* ----------------------------------------------------------------------------
    80 * Name:       CVDecTestEngine::ConstructL()
    81 * Purpose:    Symbian second phase constructor, which may leave
    82 * Parameters: MVDecEngineObserver& aTestClass
    83 * Return:     None
    84 * --------------------------------------------------------------------------*/
    85 
    86 
    87 void CVDecTestEngine::ConstructL(MVDecEngineObserver& aTestClass)
    88 {
    89 	iState = EStateNone;
    90 	iTestClass = &aTestClass;
    91 	iScreenDevice = NULL;
    92 
    93 	//Create Active object
    94 	iDecTestAO = new(ELeave) CVDecTestAO(this);
    95 
    96 	//clock source from system clock
    97 	iClock = CSystemClockSource::NewL();
    98 }
    99 
   100 
   101 /* ----------------------------------------------------------------------------
   102 * Name:       CVDecTestEngine::AssertTIntEqualL()
   103 * Purpose:
   104 *
   105 * Parameters: TInt aExpected, TInt aActual
   106 * Return:     None
   107 * --------------------------------------------------------------------------*/
   108 
   109 void CVDecTestEngine::AssertTIntEqualL(TInt aExpected, TInt aActual)
   110 {
   111 	if ( aExpected != aActual )
   112 	{
   113 		User::Leave(aActual);
   114 	}
   115 }
   116 
   117 /* ----------------------------------------------------------------------------
   118 * Name:       CVDecTestEngine::SetUp()
   119 * Purpose:    Create DevVideoPlay, Initilize Engine paramters
   120 * Parameters: TSize aSize, TBool aScreenAccess, TBool aSynchronized, TBool aCIBuffMgmt
   121 * Return:     None
   122 * --------------------------------------------------------------------------*/
   123 
   124 void CVDecTestEngine::SetUpL(TSize aSize, TBool aScreenAccess, TBool aCIBuffMgmt)
   125 {
   126 
   127 	iMemAlloc = 0;
   128 	iMemDelete = 0;
   129 	//Create DevVideoPlay
   130 	iDevvp = CMMFDevVideoPlay::NewL(*this);
   131 	PRINT((_L("CVDecTestEngine::SetUpL, DevVideo Created")))
   132 	#ifdef __MEM_CHECK_
   133 	PRINT((_L("CVDecTestEngine::SetUpL, mem alloc, iDevvp") ))
   134 	#endif
   135 	iMemAlloc++;
   136 	iState = ECreated;
   137 
   138 	// Initilize Engine parameters
   139 	iError = KErrNone;
   140 	iDecHWDevId = 0;
   141 	iPostProcId = 0;
   142 	iInBuffSize = 0;
   143 	iRawDataArea = NULL;
   144 	iCodecType = ENoCodec;
   145 	iInputEnd = EFalse;
   146 	iFrameMatch = EFalse;
   147 	iFrameJump = 0;
   148 	iFrameJumpCounter = 0;
   149 	iCorruptMarker = EFalse;
   150 	iOutCorruptedFileOpen = EFalse;
   151 	iFrameCounter = 0;
   152 	iCorruptCounter = 0;
   153 	iFlvCounter = 0;
   154 	iFrameDropCounter = 0;
   155 	iFrameDropInterval = 0;
   156 	iFrameDropNum = 0;
   157 	iFrameDropMarker = EFalse;
   158 	iCurrentFilePos = 0;
   159 	iFrameDropNumCounter = 0;
   160 	iSetPassword = EFalse;
   161 	iUseSecondScreen = EFalse;
   162 
   163 
   164 	#ifdef __CI_HEADERS__
   165 	iCIBuffMgmtOn = aCIBuffMgmt;
   166 	#endif
   167 
   168 	iDirectScreenAccess = aScreenAccess;
   169 	iSynchronized = EFalse;
   170 	iLandscapeMode =EFalse;
   171 
   172 	PRINT((_L("CVDecTestEngine::SetUpL, reserving data chunk")));
   173 
   174 
   175 	if (aSize.iWidth > 720 && aSize.iWidth > 576 )
   176 	{
   177 		iDataChunkSize = KMP4MaxCodedSize720P*4;
   178 		iDataThreshold = KMP4MaxCodedSize720P;
   179 	}
   180 	else if (aSize.iWidth > 640 && aSize.iWidth > 480 )
   181 	{
   182 		iDataChunkSize = KMP4MaxCodedSizePAL*4;
   183 		iDataThreshold = KMP4MaxCodedSizePAL;
   184 	}
   185 	else if (aSize.iWidth > 352 && aSize.iWidth > 288 )
   186 	{
   187 		iDataChunkSize = KMP4MaxCodedSizeVGA*4;
   188 		iDataThreshold = KMP4MaxCodedSizeVGA;
   189 	}
   190 	else if (aSize.iWidth <= 352 && aSize.iWidth > 176)
   191 	{
   192 		iDataChunkSize = KMP4MaxCodedSizeCIF*4;
   193 		iDataThreshold = KMP4MaxCodedSizeCIF;
   194 	}
   195 	else
   196 	{
   197 		iDataChunkSize = KMP4MaxCodedSizeQCIF*4;
   198 		iDataThreshold = KMP4MaxCodedSizeQCIF;
   199 	}
   200 	PRINT((_L("CVDecTestEngine::SetUpL, Data chunk size is [%d]"), iDataChunkSize));
   201 	PRINT((_L("CVDecTestEngine::SetUpL, Data threshold [%d]"), iDataThreshold));
   202 	iDataChunk = new (ELeave) TUint8[iDataChunkSize];
   203 	iMemAlloc++;
   204 	#ifdef __MEM_CHECK_
   205 	PRINT((_L("CVDecTestEngine::SetUpL, mem alloc, iDataChunk") ));
   206 	#endif
   207 	iReadDataChunk = iDataChunk;
   208 	iWriteDataChunk = iDataChunk;
   209 
   210 
   211 	iPictureSize.SetSize(aSize.iWidth,aSize.iHeight);
   212 	TRect rect(iPictureSize);
   213 	iDispRect = rect;
   214 	iFrameMeasurement = EFalse;
   215 	iDsaStarted = EFalse;
   216 
   217 	if ( aScreenAccess )
   218 	{
   219 		User::LeaveIfError( FbsStartup() );
   220 		PRINT((_L("CVDecTestEngine::SetUpL, Fbs server started:")))
   221 	}
   222 
   223 	//Open File session
   224 	TInt err;
   225 
   226 	if ( (err = iFs.Connect()) != KErrNone )
   227 	{
   228 		PRINT((_L("CVDecTestEngine::SetUpL, Open File server session fail ")))
   229 		User::Leave(err);
   230 	}
   231 }
   232 
   233 /* ----------------------------------------------------------------------------
   234 * Name:       CVDecTestEngine::EnableFrameMeasurementTest
   235 * Purpose:    Enable Perforamce test flag
   236 * Note
   237 * Parameters: TBool a Enable
   238 * Return:     None
   239 * --------------------------------------------------------------------------*/
   240 
   241 void CVDecTestEngine::EnableFrameMeasurementTest(TBool aEnable)
   242 {
   243 	iFrameMeasurement = aEnable;
   244 }
   245 
   246 /* ----------------------------------------------------------------------------
   247 * Name:       CVDecTestEngine::SetInputBufferSize
   248 * Purpose:
   249 * Note
   250 * Parameters: TBool a Enable
   251 * Return:     None
   252 * --------------------------------------------------------------------------*/
   253 
   254 void CVDecTestEngine::SetInputBufferSize(TInt aSize)
   255 {
   256 	iInBuffSize = aSize;
   257 	if ( iCIBuffMgmtOn )  //Custom interfarce Buffer management is used
   258 	{
   259 		PRINT((_L("CVDecTestEngine::SetInputBufferSize, CI Buffer management")))
   260 		#ifdef __CI_HEADERS__
   261 		iCIBuffMgmt = (MMmfVideoBufferManagement*)iDevvp->CustomInterface(iPostProcId, KMmfVideoBuffermanagementUid);
   262 		iCIBuffMgmt->MmvbmSetObserver(this);
   263 		iCIBuffMgmt->MmvbmEnable(ETrue);
   264 
   265 		MMmfVideoBufferManagement::TBufferOptions options;
   266 		options.iNumInputBuffers = KNumOfInputBuffers;
   267 		options.iBufferSize = iPictureSize;
   268 
   269 		iCIBuffMgmt->MmvbmSetBufferOptionsL(options);
   270 
   271 		PRINT((_L("CVDecTestEngine::SetInputBufferSize, CI Buffer management Set, Buff size:[%d],[%d]"),iPictureSize.iWidth,iPictureSize.iHeight))
   272 		#endif
   273 	}
   274 
   275 	else  //Use default Devvideo API for buffer management
   276 	{
   277 
   278 		iRawInBuffer = new(ELeave) TVideoPicture;
   279 		iMemAlloc++;
   280 		#ifdef __MEM_CHECK_
   281 		PRINT((_L("CVDecTestEngine::SetInputBufferSize, mem alloc, iRawInBuffer") ));
   282 		#endif
   283 		TUint8* ptr = new (ELeave) TUint8[iInBuffSize];
   284 		iMemAlloc++;
   285 		#ifdef __MEM_CHECK_
   286 		PRINT((_L("CVDecTestEngine::SetInputBufferSize, mem alloc, ptr") ));
   287 		#endif
   288 		TPtr8*  temp = new (ELeave) TPtr8(ptr, 0, iInBuffSize);
   289 		iMemAlloc++;
   290 		#ifdef __MEM_CHECK_
   291 		PRINT((_L("CVDecTestEngine::SetInputBufferSize, mem alloc, temp") ));
   292 		#endif
   293 		iRawInBuffer->iData.iRawData = temp;
   294 
   295 		iRawInBuffer->iData.iDataSize.SetSize(iPictureSize.iWidth,iPictureSize.iHeight); //set picture size
   296 
   297 		iRawInBuffer->iOptions = 0;
   298 		iRawInBuffer->iTimestamp = 0;
   299 		delete ptr;
   300 		iMemDelete++;
   301 		delete temp;
   302 		iMemDelete++;
   303 		#ifdef __MEM_CHECK_
   304 		PRINT((_L("CVDecTestEngine::SetInputBufferSize, mem del, ptr & temp") ));
   305 		#endif
   306 		PRINT((_L("CVDecTestEngine::SetInputBufferSize, Buffer created: Size[%d]"),iInBuffSize))
   307 	}
   308 }
   309 
   310 
   311 /* ----------------------------------------------------------------------------
   312 * Name:       CVDecTestEngine::GetHeaderInformationL()
   313 * Purpose:    Ritrieve header  Information
   314 * Parameters: TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aDataUnitEncapsulation
   315 * Return:     None
   316 *---------------------------------------------------------------------------*/
   317 
   318 void CVDecTestEngine::GetHeaderInformationL(TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aDataUnitEncapsulation)
   319 {
   320 	TInt err = KErrNone;
   321 	TVideoPictureHeader* headerInfo = NULL;
   322 	HBufC8* tempBuff = NULL;
   323 
   324 	//Read Picture header : Size is not known
   325 	TVideoInputBuffer* codedBuffer = new(ELeave) TVideoInputBuffer;
   326 	iMemAlloc++;
   327 	CleanupStack::PushL( codedBuffer );
   328 	#ifdef __MEM_CHECK_
   329 	PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem alloc, codedBuffer") ))
   330 	#endif
   331 	iInBuffSize = KMaxCodedSize;
   332 	err = KErrOverflow;
   333 
   334 	while ( (err == KErrOverflow) && (iInBuffSize <= KMaxCodedSize) )
   335 	{
   336 		tempBuff = HBufC8::NewL(iInBuffSize);
   337 		iMemAlloc++;
   338 		CleanupStack::PushL( tempBuff );
   339 		#ifdef __MEM_CHECK_
   340 		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem alloc, codedBuffer") ))
   341 		#endif
   342 		codedBuffer->iData.Set(tempBuff->Des());
   343 		if ( iFrameSizeList.Count() > 0 )
   344 		{
   345 			err = ReadOneCodedPicture(codedBuffer, iFrameSizeList[0] );
   346 		}
   347 		else
   348 		{
   349 			err = ReadOneCodedPicture(codedBuffer);
   350 		}
   351 
   352 		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, return err [%d]"),err))
   353 		TInt pos =0;
   354 		if ( iInFile.Seek(ESeekStart,pos) )
   355 		{
   356 			err = KErrGeneral;
   357 			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, err = KErrGeneral")))
   358 		}
   359 
   360 		if ( iInputEnd )
   361 		{
   362 			err = KErrNotFound;
   363 			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, err = KErrNotFound")))
   364 		}
   365 
   366 		if ( err < 0 )
   367 		{
   368 			CleanupStack::PopAndDestroy(tempBuff);
   369 			iMemDelete++;
   370 			#ifdef __MEM_CHECK_
   371 			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem del, tempBuff") ))
   372 			#endif
   373 			iInBuffSize = 4*iInBuffSize;
   374 		}
   375 	}
   376 
   377 	// Reitrieve header information from bitstream
   378 	if ( err < 0 )
   379 	{
   380 		CleanupStack::PopAndDestroy(codedBuffer);
   381 		iMemDelete++;
   382 		#ifdef __MEM_CHECK_
   383 		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem del, codedBuffer") ))
   384 		#endif
   385 		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Reading input data fail")))
   386 	}
   387 	else
   388 	{
   389 		err = KErrNone;
   390 		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, call adaptation layer")))
   391 		headerInfo = iDevvp->GetHeaderInformationL(aDataUnitType,aDataUnitEncapsulation,codedBuffer);
   392 
   393 		CleanupStack::PopAndDestroy(tempBuff);
   394 		iMemDelete++;
   395 		CleanupStack::PopAndDestroy(codedBuffer);
   396 		iMemDelete++;
   397 		#ifdef __MEM_CHECK_
   398 		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem del, tempBuff & codedBuffer") ))
   399 		#endif
   400 		//Check Header info
   401 		if ( !err && headerInfo )
   402 		{
   403 			//Size in Memory
   404 			iPictureSize = headerInfo->iDisplayedRect.Size();
   405 			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Picture Size :width[%d], height[%d]"),iPictureSize.iWidth,iPictureSize.iHeight))
   406 
   407 			// Display rect
   408 			iDispRect = headerInfo->iDisplayedRect;
   409 			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Displayed image portion: Width[%d] to Height[%d]"),headerInfo->iDisplayedRect.Width(),headerInfo->iDisplayedRect.Height()))
   410 
   411 			//return headerInfo
   412 			iDevvp->ReturnHeader(headerInfo);
   413 
   414 		}
   415 		else  //temp modify because MP4HwDevice of Emuzed returns null information in 1st release
   416 		{
   417 			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Get header info fail")))
   418 			err = KErrGeneral;
   419 		}
   420 	}
   421 
   422 	AssertTIntEqualL(KErrNone, err);
   423 
   424 }
   425 
   426 
   427 /* ----------------------------------------------------------------------------
   428 * Name:       CVDecTestEngine::GetHeaderInformationL()
   429 * Purpose:    Retrieve header Information
   430 * Parameters: None
   431 * Return:     None
   432 *---------------------------------------------------------------------------*/
   433 
   434 void CVDecTestEngine::GetHeaderInformationL()
   435 {
   436 	PRINT((_L("CVDecTestEngine::GetHeaderInformationL, In")))
   437 	TInt err = KErrNone;
   438 	TVideoPictureHeader* headerInfo = NULL;
   439 	HBufC8* tempBuff = NULL;
   440 
   441 	//Read Picture header : Size is not known
   442 	TVideoInputBuffer* codedBuffer = new(ELeave) TVideoInputBuffer;
   443 	iMemAlloc++;
   444 	CleanupStack::PushL( codedBuffer );
   445 	#ifdef __MEM_CHECK_
   446 	PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem alloc, codedBuffer") ))
   447 	#endif
   448 	iInBuffSize = KMaxCodedSize;
   449 	err = KErrOverflow;
   450 
   451 	while ( (err == KErrOverflow) && (iInBuffSize <= KMaxCodedSize) )
   452 	{
   453 		tempBuff = HBufC8::NewL(iInBuffSize);
   454 		iMemAlloc++;
   455 		CleanupStack::PushL( tempBuff );
   456 		#ifdef __MEM_CHECK_
   457 		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem alloc, tempBuff") ))
   458 		#endif
   459 		codedBuffer->iData.Set(tempBuff->Des());
   460 
   461 		if ( iFrameSizeList.Count() > 0 )
   462 		{
   463 			err = ReadOneCodedPicture(codedBuffer, iFrameSizeList[0] );
   464 		}
   465 		else
   466 		{
   467 			err = ReadOneCodedPicture(codedBuffer);
   468 		}
   469 
   470 
   471 		TInt pos =0;
   472 		if ( iInFile.Seek(ESeekStart,pos) )
   473 		{
   474 			err = KErrGeneral;
   475 		}
   476 
   477 		if ( iInputEnd )
   478 		{
   479 			err = KErrNotFound;
   480 		}
   481 
   482 		if ( err < 0 )
   483 		{
   484 			CleanupStack::PopAndDestroy(tempBuff);
   485 			iMemDelete++;
   486 			#ifdef __MEM_CHECK_
   487 			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem del, tempBuff") ))
   488 			#endif
   489 			iInBuffSize = 4*iInBuffSize;
   490 		}
   491 	}
   492 
   493 
   494 	// Reitrieve header information from bitstream
   495 	if ( err  < 0 )
   496 	{
   497 		CleanupStack::PopAndDestroy(codedBuffer);
   498 		iMemDelete++;
   499 		#ifdef __MEM_CHECK_
   500 		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem del, codedBuffer") ))
   501 		#endif
   502 		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Reading input data fail")))
   503 	}
   504 	else
   505 	{
   506 		err = KErrNone;
   507 
   508 		headerInfo = iDevvp->GetHeaderInformationL(EDuCodedPicture,EDuElementaryStream,codedBuffer);
   509 
   510 		CleanupStack::PopAndDestroy(tempBuff);
   511 		CleanupStack::PopAndDestroy(codedBuffer);
   512 		iMemDelete++;
   513 		iMemDelete++;
   514 		#ifdef __MEM_CHECK_
   515 		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem del, tempBuff & codedBuffer") ))
   516 		#endif
   517 
   518 		//Check Header info
   519 		if ( headerInfo )
   520 		{
   521 			//Size in Memory
   522 			iPictureSize = headerInfo->iDisplayedRect.Size();
   523 			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Picture Size :width[%d], height[%d]"),iPictureSize.iWidth,iPictureSize.iHeight))
   524 
   525 			// Display rect
   526 			iDispRect = headerInfo->iDisplayedRect;
   527 			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Displayed image portion: Width[%d] to Height[%d]"),headerInfo->iDisplayedRect.Width(),headerInfo->iDisplayedRect.Height()))
   528 
   529 			iDevvp->ReturnHeader(headerInfo);
   530 
   531 		}
   532 		else
   533 		{
   534 			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Get header info fail")))
   535 			err = KErrGeneral;
   536 		}
   537 
   538 	}
   539 
   540 	// Set size of decoder input buffer
   541 	if ( iCodecType == EH263 )
   542 	{
   543 		if ( (iPictureSize.iWidth <= 176 ) && (iPictureSize.iHeight <= 144) )
   544 		{
   545 			iInBuffSize = KH263MaxCodedSizeQCIF;
   546 		}
   547 		else
   548 		{
   549 			iInBuffSize = KH263MaxCodedSizeCIF;
   550 		}
   551 	}
   552 	else //Mpeg4
   553 	{
   554 		if ( (iPictureSize.iWidth <= 176 ) && (iPictureSize.iHeight <= 144) )
   555 		{
   556 			iInBuffSize = KMP4MaxCodedSizeQCIF;
   557 		}
   558 		else if ( (iPictureSize.iWidth <= 352 ) && (iPictureSize.iHeight <= 288) )
   559 		{
   560 			iInBuffSize = KMP4MaxCodedSizeCIF;
   561 		}
   562 
   563 		else
   564 		{
   565 			iInBuffSize = KMP4MaxCodedSizeVGA;
   566 		}
   567 
   568 	}
   569 
   570 	AssertTIntEqualL(KErrNone, err);
   571 	PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Out")))
   572 }
   573 
   574 /* ----------------------------------------------------------------------------
   575 * Name:       CVDecTestEngine::SetCodecType
   576 * Purpose:    Set Cotec type
   577 * Parameters: TVideoCodec aCodec
   578 *
   579 * Return:     None
   580 * --------------------------------------------------------------------------*/
   581 
   582 void CVDecTestEngine::SetCodecType(TVideoCodec aCodec)
   583 {
   584 	iCodecType = aCodec;
   585 }
   586 
   587 /* ----------------------------------------------------------------------------
   588 * Name:       CVDecTestEngine::GetBitstreamCountersL()
   589 * Purpose:
   590 * Parameters:
   591 *
   592 * Return:     None
   593 * --------------------------------------------------------------------------*/
   594 
   595 void CVDecTestEngine::GetBitstreamCountersL()
   596 {
   597 	PRINT((_L("CVDecTestEngine::GetBitstreamCountersL In")))
   598 
   599 	CMMFDevVideoPlay::TBitstreamCounters lCounters;
   600 
   601 	iDevvp->GetBitstreamCounters(lCounters);
   602 
   603 	PRINT((_L("CVDecTestEngine::GetBitstreamCountersL, Lost Packets = %d"),lCounters.iLostPackets))
   604 	PRINT((_L("CVDecTestEngine::GetBitstreamCountersL, Total Packets = %d"), lCounters.iTotalPackets))
   605 
   606 	PRINT((_L("CVDecTestEngine::GetBitstreamCountersL Out")))
   607 }
   608 
   609 /* ----------------------------------------------------------------------------
   610 * Name:       CVDecTestEngine::PreDecoderBufferBytes()
   611 * Purpose:
   612 * Parameters:
   613 *
   614 * Return:     None
   615 * --------------------------------------------------------------------------*/
   616 
   617 void CVDecTestEngine::PreDecoderBufferBytes()
   618 {
   619 	PRINT((_L("CVDecTestEngine::PreDecoderBufferBytes, In")))
   620 
   621 	TUint lBufferBytes = iDevvp->PreDecoderBufferBytes();
   622 	PRINT((_L("CVDecTestEngine::PreDecoderBufferBytes, Number of bytes of data in the pre-decoder buffer = %d"), lBufferBytes))
   623 
   624 	PRINT((_L("CVDecTestEngine::PreDecoderBufferBytes, Out")))
   625 }
   626 
   627 /* ----------------------------------------------------------------------------
   628 * Name:       CVDecTestEngine::PictureBufferBytes()
   629 * Purpose:
   630 * Parameters:
   631 *
   632 * Return:     None
   633 * --------------------------------------------------------------------------*/
   634 
   635 void CVDecTestEngine::PictureBufferBytes()
   636 {
   637 	PRINT((_L("CVDecTestEngine::PictureBufferBytes, In")))
   638 
   639 	TUint buffbyte =  iDevvp->PictureBufferBytes();
   640 	PRINT((_L("CVDecTestEngine::PictureBufferBytes: total amount of memory allocated [%d]"),buffbyte))
   641 
   642 	PRINT((_L("CVDecTestEngine::PictureBufferBytes, Out")))
   643 }
   644 
   645 /* ----------------------------------------------------------------------------
   646 * Name:       CVDecTestEngine::SetPostProcessTypesL()
   647 * Purpose:    Set combination of postprocessor
   648 *
   649 * Parameters: TUint32 aCombination
   650 * Return:     None
   651 * --------------------------------------------------------------------------*/
   652 
   653 void CVDecTestEngine::SetPostProcessTypesL(TInt aHWDevice, TUint32 aCombination)
   654 {
   655 	PRINT((_L("CVDecTestEngine::SetPostProcessTypesL, In")))
   656 
   657 	if (aHWDevice == EPostProcessor)
   658 	{
   659 		iDevvp->SetPostProcessTypesL(iPostProcId,aCombination);
   660 	}
   661 	else
   662 	{
   663 		iDevvp->SetPostProcessTypesL(iDecHWDevId,aCombination);
   664 	}
   665 
   666 	PRINT((_L("CVDecTestEngine::SetPostProcessTypesL, Out")))
   667 }
   668 
   669 
   670 /* ----------------------------------------------------------------------------
   671 * Name:       CVDecTestEngine::SetInputCropOptionsL()
   672 * Purpose:    Set input crop
   673 *
   674 * Parameters: TRect aCrop
   675 * Return:     None
   676 * --------------------------------------------------------------------------*/
   677 
   678 void CVDecTestEngine::SetInputCropOptionsL(TInt aHWDevice, TRect aCrop)
   679 {
   680 	PRINT((_L("CVDecTestEngine::SetInputCropOptionsL, In")))
   681 
   682 	if (aHWDevice == EPostProcessor)
   683 	{
   684 		iDevvp->SetInputCropOptionsL(iPostProcId,aCrop);
   685 	}
   686 	else
   687 	{
   688 		iDevvp->SetInputCropOptionsL(iDecHWDevId,aCrop);
   689 	}
   690 
   691 	PRINT((_L("CVDecTestEngine::SetInputCropOptionsL, Out")))
   692 }
   693 
   694 /* ----------------------------------------------------------------------------
   695 * Name:       CVDecTestEngine::SetYuvToRgbOptionsL()
   696 * Purpose:    Set Yuv to Rgb options
   697 *
   698 * Parameters: TYuvToRgbOptions aOptions
   699 * Return:     None
   700 * --------------------------------------------------------------------------*/
   701 
   702 void CVDecTestEngine::SetYuvToRgbOptionsL(TInt aHWDevice, TYuvToRgbOptions aOptions)
   703 {
   704 	PRINT((_L("CVDecTestEngine::SetYuvToRgbOptionsL, In")))
   705 
   706 	if (aHWDevice == EPostProcessor)
   707 	{
   708 		iDevvp->SetYuvToRgbOptionsL(iPostProcId, aOptions);
   709 	}
   710 	else
   711 	{
   712 		iDevvp->SetYuvToRgbOptionsL(iDecHWDevId, aOptions);
   713 	}
   714 
   715 	PRINT((_L("CVDecTestEngine::SetYuvToRgbOptionsL, Out")))
   716 }
   717 
   718 
   719 /* ----------------------------------------------------------------------------
   720 * Name:       CVDecTestEngine::SetRotateOptionsL()
   721 * Purpose:    Set Rotation
   722 *
   723 * Parameters: TRotationType aRotation
   724 * Return:     None
   725 * --------------------------------------------------------------------------*/
   726 void CVDecTestEngine::SetRotateOptionsL(TInt aHWDevice, TRotationType aRotation)
   727 {
   728 	PRINT((_L("CVDecTestEngine::SetRotateOptionsL, In")))
   729 
   730 	if (aHWDevice == EPostProcessor)
   731 	{
   732 		iDevvp->SetRotateOptionsL(iPostProcId, aRotation);
   733 	}
   734 	else
   735 	{
   736 		iDevvp->SetRotateOptionsL(iDecHWDevId, aRotation);
   737 	}
   738 
   739 	PRINT((_L("CVDecTestEngine::SetRotateOptionsL, Out")))
   740 }
   741 
   742 
   743 /* ----------------------------------------------------------------------------
   744 * Name:       CVDecTestEngine::SetScaleOptionsL()
   745 * Purpose:    Set Scale with multiply factor
   746 *
   747 * Parameters: TSize aSize, TBool aAntiAliasFiltering
   748 * Return:     None
   749 * --------------------------------------------------------------------------*/
   750 void CVDecTestEngine::SetScaleOptionsL(TInt aHWDevice, TSize aSize, TBool aAntiAliasFiltering)
   751 {
   752 	PRINT((_L("CVDecTestEngine::SetScaleOptionsL, In")));
   753 
   754 	if (aHWDevice == EPostProcessor)
   755 	{
   756 		iDevvp->SetScaleOptionsL(iPostProcId, aSize, aAntiAliasFiltering);
   757 	}
   758 	else
   759 	{
   760 		iDevvp->SetScaleOptionsL(iDecHWDevId, aSize, aAntiAliasFiltering);
   761 	}
   762 
   763 	PRINT((_L("CVDecTestEngine::SetScaleOptionsL, Scale option is set:width[%d],height[%d]"), aSize.iWidth,aSize.iHeight))
   764 
   765 	PRINT((_L("CVDecTestEngine::SetScaleOptionsL, Out")));
   766 }
   767 
   768 /* ----------------------------------------------------------------------------
   769 * Name:       CVDecTestEngine::SetScaleOptionsL()
   770 * Purpose:    Set Scale with multiply factor
   771 *
   772 * Parameters: TInt aNumFactor,TInt aDenoFactor, TBool aAntiAliasFiltering
   773 * Return:     None
   774 * --------------------------------------------------------------------------*/
   775 void CVDecTestEngine::SetScaleOptionsL(TInt aNumFactor,TInt aDenoFactor, TBool aAntiAliasFiltering)
   776 {
   777 	PRINT((_L("CVDecTestEngine::SetScaleOptionsL, Out")));
   778 
   779 	TInt width =  static_cast<TInt>(iPictureSize.iWidth*aNumFactor/aDenoFactor);
   780 	TInt height = static_cast<TInt>(iPictureSize.iHeight*aNumFactor/aDenoFactor);
   781 
   782 	TSize target(width, height);
   783 
   784 	iDevvp->SetScaleOptionsL(iPostProcId, target, aAntiAliasFiltering);
   785 	PRINT((_L("CVDecTestEngine::SetScaleOptionsL, Scale option is set:width[%d],height[%d]"),target.iWidth,target.iHeight))
   786 
   787 	PRINT((_L("CVDecTestEngine::SetScaleOptionsL, Out")));
   788 }
   789 
   790 
   791 /* ----------------------------------------------------------------------------
   792 * Name:       CVDecTestEngine::SetOutputCropOptionsL()
   793 * Purpose:    Set output crop
   794 *
   795 * Parameters: TRect aCrop
   796 * Return:     None
   797 * --------------------------------------------------------------------------*/
   798 void CVDecTestEngine::SetOutputCropOptionsL(TInt aHWDevice, TRect aCrop)
   799 {
   800 	PRINT((_L("CVDecTestEngine::SetOutputCropOptionsL, In")));
   801 
   802 	if (aHWDevice == EPostProcessor)
   803 	{
   804 		iDevvp->SetOutputCropOptionsL(iPostProcId, aCrop);
   805 	}
   806 	else
   807 	{
   808 		iDevvp->SetOutputCropOptionsL(iDecHWDevId, aCrop);
   809 	}
   810 
   811 	PRINT((_L("CVDecTestEngine::SetOutputCropOptionsL, Out")));
   812 }
   813 
   814 
   815 /* ----------------------------------------------------------------------------
   816 * Name:       CVDecTestEngine::CommitL()
   817 * Purpose:    commit change of postprocessors after intialization or revert
   818 *
   819 * Parameters: None
   820 * Return:     None
   821 * --------------------------------------------------------------------------*/
   822 
   823 void CVDecTestEngine::CommitL()
   824 {
   825 	PRINT((_L("CVDecTestEngine::CommitL, In")));
   826 
   827 	iDevvp->CommitL();
   828 
   829 	PRINT((_L("CVDecTestEngine::CommitL, Out")));
   830 }
   831 
   832 /* ----------------------------------------------------------------------------
   833 * Name:       CVDecTestEngine::Revert()
   834 * Purpose:    Revert any configuration changes that have not yet been committed
   835 *
   836 * Parameters: None
   837 * Return:     None
   838 * --------------------------------------------------------------------------*/
   839 void CVDecTestEngine::Revert()
   840 {
   841 	PRINT((_L("CVDecTestEngine::Revert, In")));
   842 
   843 	iDevvp->Revert();
   844 
   845 	PRINT((_L("CVDecTestEngine::Revert, Out")));
   846 }
   847 
   848 /* ----------------------------------------------------------------------------
   849 * Name:       CVDecTestEngine::SetClockSource()
   850 * Purpose:    Set SetHrdVbvSpec
   851 * Note:       This is called before initilaized
   852 * Parameters: THrdVbvSpecification aHrdVbvSpec
   853 * Return:     None
   854 * --------------------------------------------------------------------------*/
   855 
   856 void CVDecTestEngine::SetClockSource()
   857 {
   858 	PRINT((_L("CVDecTestEngine::SetClockSource, In")))
   859 
   860 	iDevvp->SetClockSource(iClock);
   861 
   862 	PRINT((_L("CVDecTestEngine::SetClockSource, Out")))
   863 }
   864 
   865 /* ----------------------------------------------------------------------------
   866 * Name:       CVDecTestEngine::SetHrdVbvSpec()
   867 * Purpose:    Set SetHrdVbvSpec
   868 * Note:       This is called before initilaized
   869 * Parameters: THrdVbvSpecification aHrdVbvSpec
   870 * Return:     None
   871 * --------------------------------------------------------------------------*/
   872 
   873 void CVDecTestEngine::SetHrdVbvSpec(THrdVbvSpecification aHrdVbvSpec, const TDesC8& aHrdVbvParams)
   874 {
   875 	PRINT((_L("CVDecTestEngine::SetHrdVbvSpec, In")))
   876 
   877 	iDevvp->SetHrdVbvSpec(aHrdVbvSpec, aHrdVbvParams);
   878 
   879 	PRINT((_L("CVDecTestEngine::SetHrdVbvSpec, Out")))
   880 }
   881 
   882 /* ----------------------------------------------------------------------------
   883 * Name:       CVDecTestEngine::SetPostProcSpecificOptionsL()
   884 * Purpose:    Set SetHrdVbvSpec
   885 * Note:       This is called before initilaized
   886 * Parameters: THrdVbvSpecification aHrdVbvSpec
   887 * Return:     None
   888 * --------------------------------------------------------------------------*/
   889 
   890 void CVDecTestEngine::SetPostProcSpecificOptionsL(TInt aHWDevice, const TDesC8& aOptions)
   891 {
   892 	PRINT((_L("CVDecTestEngine::SetPostProcSpecificOptionsL, In")))
   893 
   894 	if (aHWDevice == EPostProcessor)
   895 	{
   896 		iDevvp->SetPostProcSpecificOptionsL(iPostProcId, aOptions);
   897 	}
   898 	else
   899 	{
   900 		iDevvp->SetPostProcSpecificOptionsL(iDecHWDevId, aOptions);
   901 	}
   902 
   903 	PRINT((_L("CVDecTestEngine::SetPostProcSpecificOptionsL, Out")))
   904 }
   905 
   906 /* ----------------------------------------------------------------------------
   907 * Name:       CVDecTestEngine::SetScreenClipRegion()
   908 * Purpose:    Set SetHrdVbvSpec
   909 * Note:       This is called before initilaized
   910 * Parameters: THrdVbvSpecification aHrdVbvSpec
   911 * Return:     None
   912 * --------------------------------------------------------------------------*/
   913 
   914 void CVDecTestEngine::SetScreenClipRegion(TRegion& aRegion)
   915 {
   916 	PRINT((_L("CVDecTestEngine::SetScreenClipRegion, In")))
   917 
   918 	iDevvp->SetScreenClipRegion(aRegion);
   919 
   920 	PRINT((_L("CVDecTestEngine::SetScreenClipRegion, Out")))
   921 }
   922 
   923 /* ----------------------------------------------------------------------------
   924 * Name:       CVDecTestEngine::SetPauseOnClipFail()
   925 * Purpose:    Set SetHrdVbvSpec
   926 * Note:       This is called before initilaized
   927 * Parameters: THrdVbvSpecification aHrdVbvSpec
   928 * Return:     None
   929 * --------------------------------------------------------------------------*/
   930 
   931 void CVDecTestEngine::SetPauseOnClipFail(TBool aPause)
   932 {
   933 	PRINT((_L("CVDecTestEngine::SetPauseOnClipFail, In")))
   934 
   935 	iDevvp->SetPauseOnClipFail(aPause);
   936 
   937 	PRINT((_L("CVDecTestEngine::SetPauseOnClipFail, Out")))
   938 }
   939 
   940 /* ----------------------------------------------------------------------------
   941 * Name:       CVDecTestEngine::IsPlaying()
   942 * Purpose:    Set SetHrdVbvSpec
   943 * Note:       This is called before initilaized
   944 * Parameters: THrdVbvSpecification aHrdVbvSpec
   945 * Return:     None
   946 * --------------------------------------------------------------------------*/
   947 
   948 void CVDecTestEngine::IsPlaying()
   949 {
   950 	PRINT((_L("CVDecTestEngine::IsPlaying, In")))
   951 
   952 	TUint playing = iDevvp->IsPlaying();
   953 	PRINT((_L("CVDecTestEngine::IsPlaying, [%d]"), playing))
   954 
   955 	PRINT((_L("CVDecTestEngine::IsPlaying, Out")))
   956 
   957 }
   958 
   959 /* ----------------------------------------------------------------------------
   960 * Name:       CVDecTestEngine::GetPictureCounters()
   961 * Purpose:    Set SetHrdVbvSpec
   962 * Note:       This is called before initilaized
   963 * Parameters: THrdVbvSpecification aHrdVbvSpec
   964 * Return:     None
   965 * --------------------------------------------------------------------------*/
   966 
   967 void CVDecTestEngine::GetPictureCounters()
   968 {
   969 	PRINT((_L("CVDecTestEngine::GetPictureCounters, In")))
   970 
   971 	CMMFDevVideoPlay::TPictureCounters counters;
   972 	iDevvp->GetPictureCounters(counters);
   973 
   974 	PRINT((_L("CVDecTestEngine::GetPictureCounters, iPicturesSkipped, [%d]"), counters.iPicturesSkipped))
   975 	PRINT((_L("CVDecTestEngine::GetPictureCounters, iPicturesDecoded, [%d]"), counters.iPicturesDecoded))
   976 	PRINT((_L("CVDecTestEngine::GetPictureCounters, iPicturesDisplayed, [%d]"), counters.iPicturesDisplayed))
   977 	PRINT((_L("CVDecTestEngine::GetPictureCounters, iTotalPictures, [%d]"), counters.iTotalPictures))
   978 
   979 	PRINT((_L("CVDecTestEngine::GetPictureCounters, Out")))
   980 }
   981 
   982 /* ----------------------------------------------------------------------------
   983 * Name:       CVDecTestEngine::NumFreeBuffers()
   984 * Purpose:    Set SetHrdVbvSpec
   985 * Note:       This is called before initilaized
   986 * Parameters: THrdVbvSpecification aHrdVbvSpec
   987 * Return:     None
   988 * --------------------------------------------------------------------------*/
   989 
   990 void CVDecTestEngine::NumFreeBuffers()
   991 {
   992 	PRINT((_L("CVDecTestEngine::NumFreeBuffers, In")))
   993 
   994 	TUint playing = iDevvp->NumFreeBuffers();
   995 	PRINT((_L("CVDecTestEngine::NumFreeBuffers, [%d]"), playing))
   996 
   997 	PRINT((_L("CVDecTestEngine::NumFreeBuffers, Out")))
   998 
   999 }
  1000 
  1001 /* ----------------------------------------------------------------------------
  1002 * Name:       CVDecTestEngine::NumComplexityLevels()
  1003 * Purpose:    Set SetHrdVbvSpec
  1004 * Note:       This is called before initilaized
  1005 * Parameters: THrdVbvSpecification aHrdVbvSpec
  1006 * Return:     None
  1007 * --------------------------------------------------------------------------*/
  1008 
  1009 void CVDecTestEngine::NumComplexityLevels(TInt aHWDevice)
  1010 {
  1011 	PRINT((_L("CVDecTestEngine::NumComplexityLevels, In")))
  1012 
  1013 	TUint number = 0;
  1014 	if (aHWDevice == EPostProcessor)
  1015 	{
  1016 		number = iDevvp->NumComplexityLevels(iPostProcId);
  1017 	}
  1018 	else
  1019 	{
  1020 		number = iDevvp->NumComplexityLevels(iDecHWDevId);
  1021 	}
  1022 
  1023 	PRINT((_L("CVDecTestEngine::NumComplexityLevels, [%d]"), number))
  1024 
  1025 	PRINT((_L("CVDecTestEngine::NumComplexityLevels, Out")))
  1026 }
  1027 
  1028 /* ----------------------------------------------------------------------------
  1029 * Name:       CVDecTestEngine::InputEnd()
  1030 * Purpose:    Set SetHrdVbvSpec
  1031 * Note:       This is called before initilaized
  1032 * Parameters: THrdVbvSpecification aHrdVbvSpec
  1033 * Return:     None
  1034 * --------------------------------------------------------------------------*/
  1035 
  1036 void CVDecTestEngine::InputEnd()
  1037 {
  1038 	PRINT((_L("CVDecTestEngine::InputEnd, In")))
  1039 
  1040 	iDevvp->InputEnd();
  1041 
  1042 	PRINT((_L("CVDecTestEngine::InputEnd, Out")))
  1043 }
  1044 
  1045 /* ----------------------------------------------------------------------------
  1046 * Name:       CVDecTestEngine::GetNewPictureInfo()
  1047 * Purpose:    Set SetHrdVbvSpec
  1048 * Note:       This is called before initilaized
  1049 * Parameters: THrdVbvSpecification aHrdVbvSpec
  1050 * Return:     None
  1051 * --------------------------------------------------------------------------*/
  1052 
  1053 void CVDecTestEngine::GetNewPictureInfo(TTimeIntervalMicroSeconds& aEarliestTimestamp,
  1054 TTimeIntervalMicroSeconds& aLatestTimestamp)
  1055 {
  1056 	PRINT((_L("CVDecTestEngine::GetNewPictureInfo, In")))
  1057 
  1058 	TUint numbers = 0;
  1059 	iDevvp->GetNewPictureInfo(numbers, aEarliestTimestamp, aLatestTimestamp);
  1060 	PRINT((_L("CVDecTestEngine::GetNewPictureInfo, [%d]"), numbers))
  1061 
  1062 	PRINT((_L("CVDecTestEngine::GetNewPictureInfo, Out")))
  1063 }
  1064 
  1065 
  1066 /* ----------------------------------------------------------------------------
  1067 * Name:       CVDecTestEngine::GetTimedSnapshotL()
  1068 * Purpose:    Set SetHrdVbvSpec
  1069 * Note:       This is called before initilaized
  1070 * Parameters: THrdVbvSpecification aHrdVbvSpec
  1071 * Return:     None
  1072 * --------------------------------------------------------------------------*/
  1073 
  1074 void CVDecTestEngine::GetTimedSnapshotL(const TUncompressedVideoFormat& aFormat,
  1075 const TTimeIntervalMicroSeconds& aPresentationTimestamp)
  1076 {
  1077 	PRINT((_L("CVDecTestEngine::GetTimedSnapshotL, In")))
  1078 
  1079 	iPictureDataSnapshot.iDataFormat = aFormat.iDataFormat;
  1080 	iPictureDataSnapshot.iDataSize = iPictureSize;
  1081 
  1082 	PrintUncompressedFormat(aFormat);
  1083 
  1084 	iDevvp->GetTimedSnapshotL(&iPictureDataSnapshot, aFormat, aPresentationTimestamp);
  1085 
  1086 	PRINT((_L("CVDecTestEngine::GetTimedSnapshotL, Out")))
  1087 }
  1088 
  1089 /* ----------------------------------------------------------------------------
  1090 * Name:       CVDecTestEngine::GetTimedSnapshotL()
  1091 * Purpose:    Set SetHrdVbvSpec
  1092 * Note:       This is called before initilaized
  1093 * Parameters: THrdVbvSpecification aHrdVbvSpec
  1094 * Return:     None
  1095 * --------------------------------------------------------------------------*/
  1096 
  1097 void CVDecTestEngine::GetTimedSnapshotL(const TUncompressedVideoFormat& aFormat,
  1098 const TPictureId& aPictureId)
  1099 {
  1100 	PRINT((_L("CVDecTestEngine::GetTimedSnapshotL, In")))
  1101 
  1102 	iPictureDataSnapshot.iDataFormat = aFormat.iDataFormat;
  1103 	iPictureDataSnapshot.iDataSize = iPictureSize;
  1104 
  1105 	PrintUncompressedFormat(aFormat);
  1106 
  1107 	iDevvp->GetTimedSnapshotL(&iPictureDataSnapshot, aFormat, aPictureId);
  1108 
  1109 	PRINT((_L("CVDecTestEngine::GetTimedSnapshotL, Out")))
  1110 }
  1111 
  1112 /* ----------------------------------------------------------------------------
  1113 * Name:       CVDecTestEngine::CancelTimedSnapshot()
  1114 * Purpose:    Set SetHrdVbvSpec
  1115 * Note:       This is called before initilaized
  1116 * Parameters: THrdVbvSpecification aHrdVbvSpec
  1117 * Return:     None
  1118 * --------------------------------------------------------------------------*/
  1119 
  1120 void CVDecTestEngine::CancelTimedSnapshot()
  1121 {
  1122 	PRINT((_L("CVDecTestEngine::CancelTimedSnapshot, In")))
  1123 
  1124 	iDevvp->CancelTimedSnapshot();
  1125 
  1126 	PRINT((_L("CVDecTestEngine::CancelTimedSnapshot, Out")))
  1127 }
  1128 
  1129 /* ----------------------------------------------------------------------------
  1130 * Name:       CVDecTestEngine::GetSupportedSnapshotFormatsL()
  1131 * Purpose:    Set SetHrdVbvSpec
  1132 * Note:       This is called before initilaized
  1133 * Parameters: THrdVbvSpecification aHrdVbvSpec
  1134 * Return:     None
  1135 * --------------------------------------------------------------------------*/
  1136 
  1137 void CVDecTestEngine::GetSupportedSnapshotFormatsL()
  1138 {
  1139 	PRINT((_L("CVDecTestEngine::GetSupportedSnapshotFormatsL, In")))
  1140 
  1141 	RArray<TUncompressedVideoFormat> formats;
  1142 	CleanupClosePushL(formats);
  1143 
  1144 	iDevvp->GetSupportedSnapshotFormatsL(formats);
  1145 
  1146 	for (TUint i = 0; i < formats.Count(); i++)
  1147 	{
  1148 		PRINT((_L("CVDecTestEngine::GetSupportedSnapshotFormatsL, Format No.%d"), i))
  1149 		PrintUncompressedFormat(formats[i]);
  1150 	}
  1151 	CleanupStack::PopAndDestroy(&formats);
  1152 
  1153 	PRINT((_L("CVDecTestEngine::GetSupportedSnapshotFormatsL, Out")))
  1154 }
  1155 
  1156 
  1157 /* ----------------------------------------------------------------------------
  1158 * Name:       CVDecTestEngine::SetComplexityLevel()
  1159 * Purpose:    Set Complexity Level of Decode and postprocessor
  1160 * Note:       This is called after initilaized
  1161 * Parameters: TInt aDecLevel, TInt aPostProcLevel
  1162 * Return:     None
  1163 * --------------------------------------------------------------------------*/
  1164 
  1165 void CVDecTestEngine::SetComplexityLevel(TInt aHWDevice, TInt aLevel)
  1166 {
  1167 	PRINT((_L("CVDecTestEngine::SetComplexityLevel, In")))
  1168 
  1169 	if (aHWDevice == EPostProcessor)
  1170 	{
  1171 		iDevvp->SetComplexityLevel(iPostProcId, aLevel);
  1172 	}
  1173 	else
  1174 	{
  1175 		iDevvp->SetComplexityLevel(iDecHWDevId, aLevel);
  1176 	}
  1177 
  1178 	PRINT((_L("CVDecTestEngine::SetComplexityLevel, Out")))
  1179 }
  1180 
  1181 
  1182 
  1183 /* ----------------------------------------------------------------------------
  1184 * Name:       CVDecTestEngine::GetComplexityLevelInfo()
  1185 * Purpose:    Get number and information of Complexity Level of Decode and postprocessor
  1186 * Note:       This is called after initilaized
  1187 * Parameters: None
  1188 * Return:     None
  1189 * --------------------------------------------------------------------------*/
  1190 
  1191 void CVDecTestEngine::GetComplexityLevelInfo(TInt aHWDevice, TInt aLevel)
  1192 {
  1193 	PRINT((_L("CVDecTestEngine::GetComplexityLevelInfo, In")))
  1194 
  1195 	CMMFDevVideoPlay::TComplexityLevelInfo info;
  1196 
  1197 	if (aHWDevice == EPostProcessor)
  1198 	{
  1199 		iDevvp->GetComplexityLevelInfo(iPostProcId, aLevel, info);
  1200 	}
  1201 	else
  1202 	{
  1203 		iDevvp->GetComplexityLevelInfo(iDecHWDevId, aLevel, info);
  1204 	}
  1205 
  1206 	PRINT((_L("CVDecTestEngine::GetComplexityLevelInfo, dec complexy level info[%x]"),info.iOptions))
  1207 	PRINT((_L("CVDecTestEngine::GetComplexityLevelInfo, iAvgPictureRate [%f]"),info.iAvgPictureRate))
  1208 	PRINT((_L("CVDecTestEngine::GetComplexityLevelInfo, iPictureSize width [%d] height[%d]"),info.iPictureSize.iWidth, info.iPictureSize.iHeight))
  1209 	PRINT((_L("CVDecTestEngine::GetComplexityLevelInfo, iRelativeImageQuality [%f]"),info.iRelativeImageQuality))
  1210 	PRINT((_L("CVDecTestEngine::GetComplexityLevelInfo, iRequiredMIPS [%d]"),info.iRequiredMIPS))
  1211 	PRINT((_L("CVDecTestEngine::GetComplexityLevelInfo, iRelativeProcessTime [%f]"),info.iRelativeProcessTime))
  1212 
  1213 	PRINT((_L("CVDecTestEngine::GetComplexityLevelInfo, Out")))
  1214 }
  1215 
  1216 
  1217 /* ----------------------------------------------------------------------------
  1218 * Name:       CVDecTestEngine::Redraw()
  1219 * Purpose:    Redraw latest picture
  1220 * Note:       only applicable when DSA is used and after initilaized
  1221 * Parameters: None
  1222 * Return:     None
  1223 * --------------------------------------------------------------------------*/
  1224 
  1225 void CVDecTestEngine::Redraw()
  1226 {
  1227 	PRINT((_L("CVDecTestEngine::Redraw, In")))
  1228 
  1229 	iDevvp->Redraw();
  1230 
  1231 	PRINT((_L("CVDecTestEngine::Redraw, Out")))
  1232 }
  1233 
  1234 
  1235 
  1236 /* ----------------------------------------------------------------------------
  1237 * Name:       CVDecTestEngine::GetSnapshotL()
  1238 * Purpose:
  1239 * Note:
  1240 * Parameters: None
  1241 * Return:     None
  1242 * --------------------------------------------------------------------------*/
  1243 
  1244 void CVDecTestEngine::GetSnapshotL(TUncompressedVideoFormat& aFormat)
  1245 {
  1246 	PRINT((_L("CVDecTestEngine::GetSnapshotL, In")))
  1247 
  1248 	TInt result;
  1249 	TInt err = KErrNone;
  1250 
  1251 	TPictureData picture;
  1252 
  1253 	picture.iDataFormat = aFormat.iDataFormat;
  1254 	picture.iDataSize = iPictureSize;
  1255 
  1256 	PRINT((_L("CVDecTestEngine::GetSnapshotL, before new []")))
  1257 	TUint8* data = new (ELeave)TUint8[iPictureSize.iWidth*iPictureSize.iHeight*2];
  1258 	PRINT((_L("CVDecTestEngine::GetSnapshotL, after new[]")))
  1259 
  1260 	TPtr8 dataPtr(data, iPictureSize.iWidth*iPictureSize.iHeight*2);
  1261 	picture.iRawData = &dataPtr;
  1262 
  1263 	CleanupStack::PushL(data);
  1264 	iMemAlloc++;
  1265 	#ifdef __MEM_CHECK_
  1266 	PRINT((_L("CVDecTestEngine::GetSnapshotL, mem alloc, data") ))
  1267 	#endif
  1268 	PRINT((_L("CVDecTestEngine::GetSnapshotL, before snapshot")))
  1269 	result = iDevvp->GetSnapshotL(picture, aFormat);
  1270 
  1271 	PRINT((_L("CVDecTestEngine::GetSnapshotL, snapshot received")))
  1272 	if ( !result )
  1273 	{
  1274 		RFile snapshot;
  1275 
  1276 		TFileName filename;
  1277 		TBuf8<128> newFile;
  1278 		newFile.Append(iInFileName);
  1279 		TBuf16<128> temp2;
  1280 		temp2.Copy(newFile);
  1281 		PRINT((_L("CVDecTestEngine::GetSnapshotL, Opening the file [%S]"), &temp2))
  1282 		newFile.Delete(newFile.Length()-4, 4);
  1283 		newFile.Append(_L8("_snapshot"));
  1284 		newFile.Append(_L8(".yuv"));
  1285 		filename.Copy(newFile);
  1286 
  1287 		TBuf16<128> temp;
  1288 		temp.Copy(newFile);
  1289 
  1290 		PRINT((_L("CVDecTestEngine::GetSnapshotL, Opening the file [%S]"), &temp))
  1291 		err = snapshot.Replace(iFs, filename, EFileShareExclusive|EFileWrite);
  1292 
  1293 		PRINT((_L("CVDecTestEngine::GetSnapshotL, writing the file")))
  1294 
  1295 		if ( err!= KErrNone )
  1296 		{
  1297 			PRINT((_L("CVDecTestEngine::GetSnapshotL, snapshot file open failed")))
  1298 			snapshot.Close();
  1299 			User::Leave(err);
  1300 		}
  1301 		else
  1302 		{
  1303 			PRINT((_L("CVDecTestEngine::GetSnapshotL, Picture size %d"),picture.iRawData->Size()));
  1304 			PRINT((_L("CVDecTestEngine::GetSnapshotL, Picture length %d"),picture.iRawData->Length()));
  1305 			err = snapshot.Write(*(picture.iRawData),picture.iRawData->Size());
  1306 			if ( err!= KErrNone )
  1307 			{
  1308 				PRINT((_L("CVDecTestEngine::GetSnapshotL, snapshot file write failed [%d]"), picture.iRawData->Size()))
  1309 				snapshot.Close();
  1310 				User::Leave(err);
  1311 			}
  1312 		}
  1313 		PRINT((_L("CVDecTestEngine::GetSnapshotL, Picture size %d"),picture.iRawData->Size()));
  1314 		snapshot.Close();
  1315 
  1316 	}
  1317 	else
  1318 	{
  1319 		PRINT((_L("CVDecTestEngine::GetSnapshotL, Error getting snapshot [%d]"), result))
  1320 	}
  1321 	CleanupStack::PopAndDestroy( data );
  1322 	iMemDelete++;
  1323 	#ifdef __MEM_CHECK_
  1324 	PRINT((_L("CVDecTestEngine::GetSnapShotL, mem del, ") ))
  1325 	#endif
  1326 	PRINT((_L("CVDecTestEngine::GetSnapshotL, Out")))
  1327 }
  1328 
  1329 
  1330 
  1331 /* ----------------------------------------------------------------------------
  1332 * Name:       CVDecTestEngine::OpenFileL()
  1333 * Purpose:    Open input File
  1334 * Note:       DSA is used, output is display
  1335 * Parameters: TFileName& aInFileName
  1336 * Return:     None
  1337 * --------------------------------------------------------------------------*/
  1338 
  1339 void CVDecTestEngine::OpenFileL(TFileName& aInFileName)
  1340 {
  1341 	PRINT((_L("CVDecTestEngine::OpenFileL, In")))
  1342 	TInt err;
  1343 	iInFileName.Copy(aInFileName);
  1344 
  1345 	if ( (err = iInFile.Open(iFs, aInFileName, EFileRead | EFileShareReadersOnly)) != KErrNone)
  1346 	{
  1347 		PRINT((_L("CVDecTestEngine::OpenFiles, Input File open Failed")));
  1348 		User::Leave(err);
  1349 	}
  1350 	PRINT((_L("CVDecTestEngine::OpenFileL, Out")))
  1351 }
  1352 
  1353 
  1354 /* ----------------------------------------------------------------------------
  1355 * Name:       CVDecTestEngine::OpenFileL()
  1356 * Purpose:    Open input and output File
  1357 * Note:       Memory buffer output is used
  1358 * Parameters: TFileName& aOutFileName, TFileName& aInFileName
  1359 * Return:     None
  1360 * --------------------------------------------------------------------------*/
  1361 
  1362 
  1363 void CVDecTestEngine::OpenFileL(TFileName& aOutFileName, TFileName& aInFileName)
  1364 {
  1365 	PRINT((_L("CVDecTestEngine::OpenFileL, In")))
  1366 	TInt err = KErrNone;
  1367 
  1368 	iInFileName.Copy(aInFileName);
  1369 	iOutFileName.Copy(aOutFileName);
  1370 	err = iInFile.Open(iFs, aInFileName, EFileRead | EFileShareReadersOnly);
  1371 
  1372 	if ( err != KErrNone)
  1373 	{
  1374 		PRINT((_L("CVDecTestEngine::OpenFiles, Input File open Failed")));
  1375 	}
  1376 
  1377 	else
  1378 	{
  1379 		iOutFileOpen = ETrue;
  1380 		err = iOutFile.Replace(iFs, aOutFileName, EFileShareExclusive|EFileWrite);
  1381 
  1382 		if ( err!= KErrNone )
  1383 		{
  1384 			PRINT((_L("CVDecTestEngine::OpenFiles, Output File Replace Failed")));
  1385 			iInFile.Close();
  1386 		}
  1387 	}
  1388 
  1389 
  1390 	AssertTIntEqualL(KErrNone,err);
  1391 	PRINT((_L("CVDecTestEngine::OpenFileL, Out")))
  1392 }
  1393 
  1394 
  1395 
  1396 /* ----------------------------------------------------------------------------
  1397 * Name:       CVDecTestEngine::CloseFile()
  1398 * Purpose:    Close File
  1399 * Note:
  1400 * Parameters:
  1401 * Return:     None
  1402 * --------------------------------------------------------------------------*/
  1403 
  1404 
  1405 void CVDecTestEngine::CloseFile()
  1406 {
  1407 
  1408 	iInFile.Close();
  1409 	if ( iOutFileOpen )
  1410 	{
  1411 		iOutFile.Close();
  1412 
  1413 		PRINT((_L("CVDecTestEngine::CloseFile, Output file closed")))
  1414 	}
  1415 
  1416 	PRINT((_L("CVDecTestEngine::CloseFile, File Closed")))
  1417 
  1418 	if( iCorruptMarker )
  1419 	{
  1420 		iFs.Delete( iOutFileName );
  1421 	}
  1422 
  1423 }
  1424 
  1425 
  1426 
  1427 /* ----------------------------------------------------------------------------
  1428 * Name:       CVDecTestEngine::FrameJump()
  1429 * Purpose:    Jump backward or forward a number of frames
  1430 * Note:
  1431 * Parameters: TInt aNumToJump
  1432 * Return:     TInt
  1433 * --------------------------------------------------------------------------*/
  1434 TInt CVDecTestEngine::FrameJump(TInt aNumToJump )
  1435 {
  1436 	PRINT((_L("CVDecTestEngine::FrameJump, In")))
  1437 	TInt err = KErrNone;
  1438 
  1439 	if ( iState == ERunning )
  1440 	{
  1441 		if ( iSynchronized )
  1442 		{
  1443 			iClock->Suspend();  //Stop Clock source
  1444 		}
  1445 
  1446 
  1447 		iDevvp->Pause();
  1448 		iState = EPaused;
  1449 		PRINT((_L("CVDecTestEngine::Pause(), Paused")))
  1450 
  1451 
  1452 		iFrameJump = aNumToJump;
  1453 
  1454 
  1455 		if( iFrameJump < 0 )
  1456 		{
  1457 			TInt startFrame = iSentBuffCount + iFrameJump;
  1458 			if( startFrame < 0 )
  1459 			{
  1460 				PRINT((_L("CVDecTestEngine::FrameJump, bad argument")))
  1461 				return KErrArgument;
  1462 			}
  1463 			else
  1464 			{
  1465 				iFrameJump = startFrame;
  1466 			}
  1467 		}
  1468 		TInt beginningPos = 0;
  1469 		iInFile.Seek(ESeekStart, beginningPos);
  1470 		RArray<TInt> vFramesizes;
  1471 		ListFrameSizeL( vFramesizes );
  1472 
  1473 		if( iFrameSizeList.Count() > iFrameJump )
  1474 		{
  1475 			TInt startPosition = 0;
  1476 			for( TInt frameCounter = 0; frameCounter < iFrameSizeList.Count();
  1477 			frameCounter++ )
  1478 			{
  1479 				startPosition += iFrameSizeList[ frameCounter ];
  1480 			}
  1481 			iInFile.Seek(ESeekStart,startPosition);
  1482 		}
  1483 		else
  1484 		{
  1485 			err = KErrGeneral;
  1486 			PRINT((_L("CVDecTestEngine::FrameJump, iFrameSizeList.Count value:[%ld]"),iFrameSizeList.Count()))
  1487 		}
  1488 
  1489 	}
  1490 	else
  1491 	{
  1492 		err = KErrGeneral;
  1493 	}
  1494 
  1495 	PRINT((_L("CVDecTestEngine::FrameJump, iFrameJump value:[%ld]"),iFrameJump))
  1496 	PRINT((_L("CVDecTestEngine::FrameJump, Out")))
  1497 
  1498 	return err;
  1499 }
  1500 
  1501 
  1502 
  1503 /* ----------------------------------------------------------------------------
  1504 * Name:       CVDecTestEngine::SetFrameMatch()
  1505 * Purpose:    The test case fails if input and output frame number doesn't
  1506 *             match
  1507 * Note:
  1508 * Parameters: TBool aMatch
  1509 * Return:     None
  1510 * --------------------------------------------------------------------------*/
  1511 void CVDecTestEngine::SetFrameMatch(TBool aMatch)
  1512 {
  1513 
  1514 	iFrameMatch = aMatch;
  1515 
  1516 	PRINT((_L("CVDecTestEngine::SetFrameMatch, frame match is set")))
  1517 }
  1518 
  1519 
  1520 /* ----------------------------------------------------------------------------
  1521 * Name:       CVDecTestEngine::Initialize()
  1522 * Purpose:    Initilize Decoder/Postprocessor
  1523 * Note:
  1524 * Parameters: TBool aSynchronized
  1525 * Return:     None
  1526 * --------------------------------------------------------------------------*/
  1527 
  1528 
  1529 TInt CVDecTestEngine::Initialize()
  1530 {
  1531 	PRINT((_L("CVDecTestEngine::Initialize, In")))
  1532 
  1533 	iError = KErrNone;
  1534 
  1535 	// Do Initialization
  1536 	iDevvp->Initialize();
  1537 	PRINT((_L("CVDecTestEngine::Initialize, Initialize() returned")))
  1538 	if ( (iState != EInitialized) && (iError == KErrNone ) )
  1539 	{
  1540 		iScheduler = new (ELeave) CActiveSchedulerWait;
  1541 		iMemAlloc++;
  1542 		#ifdef __MEM_CHECK_
  1543 		PRINT((_L("CVDecTestEngine::Initialize, mem alloc, iScheduler") ))
  1544 		#endif
  1545 		iRunning = ETrue;
  1546 		iScheduler->Start();
  1547 	}
  1548 	PRINT((_L("CVDecTestEngine::Initialize, out: error[%d]"),iError))
  1549 	return iError;
  1550 }
  1551 
  1552 /* ----------------------------------------------------------------------------
  1553 * Name:       CVDecTestEngine::InitializeAndDelete()
  1554 * Purpose:    Initilize Decoder/Postprocessor
  1555 * Note:
  1556 * Parameters: TBool aSynchronized
  1557 * Return:     None
  1558 * --------------------------------------------------------------------------*/
  1559 
  1560 
  1561 TInt CVDecTestEngine::InitializeAndDelete()
  1562 {
  1563 	PRINT((_L("CVDecTestEngine::InitializeAndDelete, In")))
  1564 
  1565 	iDeleteDecoderFromInitComp = ETrue;
  1566 
  1567 	TInt err = Initialize();
  1568 
  1569 	PRINT((_L("CVDecTestEngine::InitializeAndDelete, Out")))
  1570 	return err;
  1571 }
  1572 
  1573 /* ----------------------------------------------------------------------------
  1574 * Name:       CVDecTestEngine::Start()
  1575 * Purpose:    Start Decoding/Postprocessing
  1576 * Note:
  1577 * Parameters: None
  1578 * Return:     None
  1579 * --------------------------------------------------------------------------*/
  1580 
  1581 
  1582 TInt CVDecTestEngine::Start(TBool aInputEnd)
  1583 {
  1584 
  1585 	TInt err = KErrNone;
  1586 	iDisableInputEnd = aInputEnd;
  1587 	
  1588 	PRINT((_L("CVDecTestEngine::Start, Devvideo play started")))
  1589 
  1590 	// Start DSA
  1591 	if ( iDirectScreenAccess && !iDsaStarted )
  1592 	{
  1593 		TRAPD(err, StartDirectScreenAccessL());
  1594 		if (err != KErrNone)
  1595 		{
  1596 			return err;
  1597 		}
  1598 
  1599 	}
  1600 
  1601     // Start DevVideoPlay
  1602     iDevvp->Start();
  1603     iState = ERunning;
  1604     
  1605 	//Reset Clock at Stream Start
  1606 	if ( iSynchronized )
  1607 	{
  1608 		TTimeIntervalMicroSeconds offset(KStartOffset);
  1609 		Int64 time = offset.Int64();
  1610 		iClock->Reset(offset);
  1611 	}
  1612 
  1613 
  1614 	// Start Data transfer
  1615 	iDecTestAO->RequestData();
  1616 
  1617 	PRINT((_L("CVDecTestEngine::Start, Start data transfer - start () out")))
  1618 	return err;
  1619 
  1620 }
  1621 
  1622 
  1623 
  1624 /* ----------------------------------------------------------------------------
  1625 * Name:       CVDecTestEngine::Stop()
  1626 * Purpose:    Stop Decoding/Postprocessing
  1627 * Note:
  1628 * Parameters: None
  1629 * Return:     None
  1630 * --------------------------------------------------------------------------*/
  1631 
  1632 
  1633 TInt CVDecTestEngine::Stop()
  1634 {
  1635 
  1636 	PRINT((_L("CVDecTestEngine::Stop, In ")))
  1637 
  1638 	if ( (iState == ERunning ) || (iState == EPaused) )
  1639 	{
  1640 		//Stop Devvideoplay
  1641         iDevvp->Stop();
  1642 		iState = EStopped;
  1643 		PRINT((_L("CVDecTestEngine::Stop, Stopped ")))
  1644 	}
  1645 
  1646 	//Stop DSA
  1647 	if ( iDirectScreenAccess && iDsaStarted )
  1648 	{
  1649 		iDevvp->AbortDirectScreenAccess();
  1650 		iDsaStarted = EFalse;
  1651 		PRINT((_L("CVDecTestEngine::Stop, DSA is aborted ")))
  1652 
  1653 		PRINT((_L("CVDecTestEngine::VDecTestStartL, the number of Pictures sent: [%d]"),iSentBuffCount))
  1654 
  1655 	}
  1656 	else if ( iInputEnd )
  1657 	{
  1658 		if ( iSentBuffCount != (iReturnedBuffCount + iPictureLoss) )
  1659 		{
  1660 			if( iFrameMatch )
  1661 			{
  1662 				PRINT((_L("CVDecTestEngine::VDecTestStopL, the number of Pictures sent and returned does not match: ")))
  1663 				return KErrGeneral;
  1664 			}
  1665 			PRINT((_L("CVDecTestEngine::VDecTestStopL, the number of Pictures sent and returned does not match: ")))
  1666 			PRINT((_L("The number of pictures, sent : [%d], returned:[%d] "),iSentBuffCount, iReturnedBuffCount ))
  1667 		}
  1668 	}
  1669 
  1670 	PRINT((_L("CVDecTestEngine::Stop, Out")))
  1671 	return iError;
  1672 }
  1673 
  1674 
  1675 
  1676 /* ----------------------------------------------------------------------------
  1677 * Name:       CVDecTestEngine::TearDown()
  1678 * Purpose:    Cleanup resources
  1679 * Note:
  1680 * Parameters: None
  1681 * Return:     None
  1682 * --------------------------------------------------------------------------*/
  1683 
  1684 
  1685 void CVDecTestEngine::TearDown()
  1686 {
  1687 	PRINT((_L("CVDecTestEngine::TearDown(),In")))
  1688 
  1689 	if( iInstantFpsEnabled )
  1690 	{
  1691 		iFpsFile.Close();
  1692 		PRINT((_L("CVDecTestEngine::CloseFile, FPS Output file closed")))
  1693 	}
  1694 
  1695 	if ( iDsaStarted )
  1696 	{
  1697 		iDevvp->AbortDirectScreenAccess();
  1698 		PRINT((_L("CVDecTestEngine::TearDown(), Dsa aborted")))
  1699 	}
  1700 
  1701 	// Delete Devvideo play
  1702 	if ( iDevvp )
  1703 	{
  1704 		delete iDevvp;
  1705 		iMemDelete++;
  1706 		#ifdef __MEM_CHECK_
  1707 		PRINT((_L("CVDecTestEngine::TearDown, mem del, iDevvp") ))
  1708 		#endif
  1709 		iDevvp = NULL;
  1710 		iState = EStateNone;
  1711 		PRINT((_L("CVDecTestEngine::TearDown(),DevVideo deleted")))
  1712 	}
  1713 
  1714 
  1715 	//Postproc input buffer
  1716 	if ( !iCIBuffMgmtOn && iRawInBuffer)
  1717 	{
  1718 		delete (TUint8*)iRawInBuffer->iData.iRawData->Ptr();
  1719 		delete iRawInBuffer->iData.iRawData;
  1720 		delete iRawInBuffer;
  1721 		iMemDelete += 3;
  1722 		#ifdef __MEM_CHECK_
  1723 		PRINT((_L("CVDecTestEngine::TearDown, mem del, iRawInBuffer & its 2 pointers") ))
  1724 		#endif
  1725 		iRawInBuffer = NULL;
  1726 	}
  1727 
  1728 	if ( iScreenDevice )
  1729 	{
  1730 		delete iScreenDevice;
  1731 		iScreenDevice = NULL;
  1732 		iMemDelete++;
  1733 		#ifdef __MEM_CHECK_
  1734 		PRINT((_L("CVDecTestEngine::TearDown, mem del, iScreenDevice") ))
  1735 		#endif
  1736 		RFbsSession::Disconnect();
  1737 	}
  1738 
  1739 	delete iDataChunk;
  1740 	iMemDelete++;
  1741 	#ifdef __MEM_CHECK_
  1742 	PRINT((_L("CVDecTestEngine::TearDown, mem del, iDataChunk") ))
  1743 	#endif
  1744 
  1745 	iDataChunk = NULL;
  1746 
  1747 	iFrameSizeList.Close();
  1748 
  1749 	iInstantFpsList.Close();
  1750 
  1751 	iFs.Close();
  1752 
  1753 	REComSession::FinalClose();
  1754 	PRINT( (_L("CVDecTestEngine::TearDown(), mem allocated: %d "), iMemAlloc))
  1755 	PRINT( (_L("CVDecTestEngine::TearDown(), mem deleted: %d "), iMemDelete))
  1756 	PRINT((_L("CVDecTestEngine::TearDown(),Out")))
  1757 }
  1758 
  1759 
  1760 
  1761 /* ----------------------------------------------------------------------------
  1762 * Name:       CVDecTestEngine::FillAndSendBufferL()
  1763 * Purpose:    Fill data into input buffer and send to devvideoplay
  1764 * Note:
  1765 * Parameters: None
  1766 * Return:     None
  1767 * --------------------------------------------------------------------------*/
  1768 
  1769 
  1770 void CVDecTestEngine::FillAndSendBufferL()
  1771 {
  1772 	PRINT((_L("CVDecTestEngine::FillAndSendBufferL(), In")))
  1773 	TInt err = KErrNone;
  1774 
  1775 	if ( iInputEnd)
  1776 	{
  1777 		iLastFrame = EFalse;
  1778 		//iCodedInBuffer->iOptions =  TVideoInputBuffer::EDecodingTimestamp;
  1779 		//iCodedInBuffer->iDecodingTimestamp = iSentBuffCount+2;
  1780 		//ReadOneCodedPicture(iCodedInBuffer, 0); // Read compressed data of one picture from file
  1781 		//iDevvp->WriteCodedDataL(iCodedInBuffer);  // Input Data Sent to Decoder
  1782 		if (!iDisableInputEnd)
  1783 		{
  1784 			iDevvp->InputEnd();
  1785 			PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Input End")))
  1786 		}
  1787 		else
  1788 		{
  1789 			MdvpoStreamEnd();
  1790 			PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Stream end")))
  1791 		}
  1792 		return;
  1793 	}
  1794 
  1795 	if ( iDecHWDevId )
  1796 	{
  1797 		PRINT((_L("CVDecTestEngine::FillAndSendBufferL(), iDecHWDevID found")))
  1798 		if (  iFrameSizeList.Count() > 0 )
  1799 		{
  1800 			if (iFrameSizeList.Count() <= iSentBuffCount+1)
  1801 			{
  1802 				iInputEnd = ETrue;
  1803 			}
  1804 			TInt size = iFrameSizeList[iSentBuffCount];
  1805 			err = ReadOneCodedPicture(iCodedInBuffer, size); // Read compressed data of one picture from file
  1806 
  1807 			PRINT((_L("CVDecTestEngine::FillAndSendBufferL(), 1 picture read")))
  1808 
  1809 			if( iFrameDropMarker )
  1810 			{
  1811 				if( iFrameDropCounter >= iFrameDropInterval )
  1812 				{
  1813 					TInt dropNum = 0;
  1814 					for( ; ;)
  1815 					{
  1816 						TInt size = iFrameSizeList[iSentBuffCount++];
  1817 						err = ReadOneCodedPicture(iCodedInBuffer, size); // Read compressed data of one picture from file
  1818 						dropNum++;
  1819 						iFrameDropNumCounter++;
  1820 						if( iFrameDropNumCounter >= iFrameDropNum )
  1821 						{
  1822 							iFrameDropCounter = 0;
  1823 							iFrameDropNumCounter = 0;
  1824 							break;
  1825 						}
  1826 					}
  1827 					PRINT((_L("CVDecTestEngine::FillAndSendBufferL(), [%d] frame(s) dropped"), dropNum))
  1828 				}
  1829 			}
  1830 
  1831 
  1832 		}
  1833 		else
  1834 		{
  1835 			err = ReadOneCodedPicture(iCodedInBuffer); // Read compressed data of one picture from file
  1836 			PRINT((_L("CVDecTestEngine::FillAndSendBufferL(), one picture read, err: [%d]"), err))
  1837 
  1838 			if( iFrameDropMarker )
  1839 			{
  1840 				if( iFrameDropCounter >= iFrameDropInterval )
  1841 				{
  1842 					TInt dropNum  = 0;
  1843 					for( ; ;)
  1844 					{
  1845 						err = ReadOneCodedPicture(iCodedInBuffer);
  1846 						dropNum++;
  1847 						iFrameDropNumCounter++;
  1848 						if( iFrameDropNumCounter >= iFrameDropNum )
  1849 						{
  1850 							iFrameDropCounter = 0;
  1851 							iFrameDropNumCounter = 0;
  1852 							break;
  1853 						}
  1854 					}
  1855 					PRINT((_L("CVDecTestEngine::FillAndSendBufferL(), [%d] frame(s) dropped"), dropNum))
  1856 				}
  1857 			}
  1858 
  1859 
  1860 		}
  1861 	}
  1862 	else  // Postproc input case
  1863 	{
  1864 		PRINT((_L("CVDecTestEngine::FillAndSendBufferL(), iDecHWDevID not found")))
  1865 		err = ReadRawPicture();	// Read raw data for one picture
  1866 		if( iFrameDropMarker )
  1867 		{
  1868 			if( iFrameDropCounter >= iFrameDropInterval )
  1869 			{
  1870 				TInt dropNum = 0;
  1871 				for( ; ;)
  1872 				{
  1873 					err = ReadRawPicture();	// Read raw data for one picture
  1874 					dropNum++;
  1875 					iFrameDropNumCounter++;
  1876 					if( iFrameDropNumCounter >= iFrameDropNum )
  1877 					{
  1878 						iFrameDropCounter = 0;
  1879 						iFrameDropNumCounter = 0;
  1880 						break;
  1881 					}
  1882 				}
  1883 				PRINT((_L("CVDecTestEngine::FillAndSendBufferL(), [%d] raw picture(s) dropped"), dropNum))
  1884 			}
  1885 		}
  1886 	}
  1887 	if(err == 0){
  1888 		PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Empty buffer read skipping")))
  1889 		PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Out")))
  1890 	}
  1891 	else if ( err > 0 )
  1892 	{
  1893 		// Corrupt the input if user requires
  1894 		/*
  1895 		if( iCorruptMarker )
  1896 		{
  1897 
  1898 		CorruptEngineL();
  1899 
  1900 		}
  1901 		*/
  1902 		// End of the corrupting operation
  1903 
  1904 		if ( iDecHWDevId )
  1905 		{
  1906 
  1907 			iCodedInBuffer->iOptions =  TVideoInputBuffer::EDecodingTimestamp;
  1908 
  1909 			if ( iPostProcId )
  1910 			{
  1911 				iCodedInBuffer->iOptions |= TVideoInputBuffer::EPresentationTimestamp;
  1912 			}
  1913 
  1914 
  1915 
  1916 			if ( iSynchronized ) // Clock source is set >> real-time synchronization
  1917 			{
  1918 				iCodedInBuffer->iDecodingTimestamp = iTimeStamp;
  1919 				if ( iPostProcId )
  1920 				{
  1921 					iCodedInBuffer->iPresentationTimestamp = iTimeStamp;
  1922 				}
  1923 
  1924 
  1925 				PRINT((_L("CVDecTestEngine::FillAndSendBufferL, iTimestamp added:[%ld]"),iTimeStamp))
  1926 				iTimeStamp += iFrameTimeInterval;
  1927 			}
  1928 			else // Clock source is not set
  1929 			{
  1930 				iCodedInBuffer->iDecodingTimestamp = iSentBuffCount;
  1931 				if ( iPostProcId )
  1932 				{
  1933 					iCodedInBuffer->iPresentationTimestamp = iSentBuffCount;
  1934 				}
  1935 
  1936 			}
  1937 
  1938 			TInt substreamID = 0;
  1939 			//      	    iCodedInBuffer->iUser = (TAny*)(&substreamID);
  1940 			if(iCodedInBuffer->iUser != NULL ){
  1941 				*((TInt*)iCodedInBuffer->iUser) = substreamID;
  1942 			}
  1943 			#if 0
  1944 			TUint32 msgSize = iCodedInBuffer->iData.Length();
  1945 			TUint8* tmpPtr = const_cast<TUint8 *>(iCodedInBuffer->iData.Ptr());
  1946 			while(msgSize > 0)
  1947 			{
  1948 				if(msgSize >= 16)
  1949 				{
  1950 					PRINT((_L("TX:%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x"),tmpPtr[0],tmpPtr[1],tmpPtr[2],tmpPtr[3],tmpPtr[4],tmpPtr[5],tmpPtr[6],tmpPtr[7],tmpPtr[8],tmpPtr[9],tmpPtr[10],tmpPtr[11],tmpPtr[12],tmpPtr[13],tmpPtr[14],tmpPtr[15]))
  1951 					msgSize -= 16;
  1952 					tmpPtr += 16;
  1953 				}
  1954 				else if(msgSize >= 4)
  1955 				{
  1956 					PRINT((_L("TX:%02x,%02x,%02x,%02x"),tmpPtr[0],tmpPtr[1],tmpPtr[2],tmpPtr[3]))
  1957 					msgSize -= 4;
  1958 					tmpPtr += 4;
  1959 				}
  1960 				else
  1961 				{
  1962 					for(TUint i = 0; i < msgSize; i++)
  1963 					{
  1964 						PRINT((_L("TX: 0x%02x"),*tmpPtr++))
  1965 					}
  1966 					msgSize = 0;
  1967 				}
  1968 			}
  1969 			#endif
  1970 
  1971 			iDevvp->WriteCodedDataL(iCodedInBuffer);  // Input Data Sent to Decoder
  1972 		    iCodedInBuffer = NULL;
  1973 		}
  1974 		else
  1975 		{
  1976 
  1977 			iRawInBuffer->iData.iDataSize.SetSize(iPictureSize.iWidth,iPictureSize.iHeight);
  1978 
  1979 			iRawInBuffer->iOptions |= (TVideoPicture::ETimestamp);
  1980 
  1981 			if ( iSynchronized )
  1982 			{
  1983 				//TTimeIntervalMicroSeconds tsValue(iTimeStamp);
  1984 				iRawInBuffer->iTimestamp = iTimeStamp;
  1985 				iTimeStamp += iFrameTimeInterval;
  1986 				PRINT((_L("CVDecTestEngine::FillAndSendBufferL, iTimestamp added:[%ld]"),iTimeStamp))
  1987 			}
  1988 			else
  1989 			{
  1990 				iRawInBuffer->iTimestamp = iSentBuffCount;
  1991 			}
  1992 
  1993 
  1994 			PRINT((_L("CVDecTestEngine::FillAndSendBufferL, data size: w[%d] ,h[%d]"),iRawInBuffer->iData.iDataSize.iWidth, iRawInBuffer->iData.iDataSize.iHeight))
  1995 			iDevvp->WritePictureL(iRawInBuffer);  // Input Data Sent to PostProcessor
  1996 
  1997 
  1998 			if (iCIBuffMgmtOn)
  1999 			{
  2000 				iRawInBuffer = NULL;
  2001 			}
  2002 
  2003 		}
  2004 
  2005 		iFrameDropCounter++;
  2006 		iSentBuffCount++;
  2007 		PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Sent Frame: [%d] "),iSentBuffCount))
  2008 
  2009 	}
  2010 	else  //Error case
  2011 	{
  2012 		iError = err;
  2013 		PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Error in reading data: [%d] "),iError))
  2014 		iInputEnd = ETrue;
  2015 		iDevvp->InputEnd();
  2016 		return;
  2017 	}
  2018 
  2019 	// if ( iFrameMeasurement )
  2020 	//    return;
  2021 
  2022 	if (iInputEnd)
  2023 	{
  2024 		iLastFrame = ETrue;
  2025 		PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Input end: sending last frame 0 ")))
  2026 		iDecTestAO->RequestData(); // Next Input Data for Decoder / PostProc
  2027 		return;
  2028 	}
  2029 
  2030 	if ( iState == ERunning )
  2031 	{
  2032 		if ( iDecHWDevId )
  2033 		{
  2034 			if (iSetFastClient)
  2035 			{
  2036 				PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Fast client request")))
  2037 				iDecTestAO->RequestData(); // Next Input Data for Decoder / PostProc
  2038 			}
  2039 			else
  2040 			{
  2041 				if ( iDevvp->NumFreeBuffers() )
  2042 				{
  2043 					iDecTestAO->RequestData(); // Next Input Data for Decoder / PostProc
  2044 				}
  2045 				else
  2046 				{
  2047 					PRINT((_L("CVDecTestEngine::FillAndSendBufferL, No input buffer available now")))
  2048 					iNoBuffAvailable++;
  2049 				}
  2050 			}
  2051 		}
  2052 	}
  2053 
  2054 
  2055 	PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Out")))
  2056 
  2057 }
  2058 
  2059 
  2060 /* ----------------------------------------------------------------------------
  2061 * Name:       CVDecTestEngine::GetInputBufferL()
  2062 * Purpose:    Ritreave decoder input buffer
  2063 * Note:
  2064 * Parameters: None
  2065 * Return:     None
  2066 * --------------------------------------------------------------------------*/
  2067 
  2068 
  2069 void CVDecTestEngine::GetInputBufferL()
  2070 {
  2071 	TBool buffer = EFalse;
  2072 
  2073 	if ( iState == ERunning )
  2074 	{
  2075 		if ( iDecHWDevId )
  2076 		{
  2077 			iCodedInBuffer = iDevvp->GetBufferL(iInBuffSize);
  2078 			if ( iCodedInBuffer )
  2079 			{
  2080 				buffer = ETrue;
  2081 			}
  2082 
  2083 		}
  2084 		else if ( iCIBuffMgmtOn )
  2085 		{
  2086 			PRINT((_L("CVDecTestEngine::GetInputBufferL(), Getting Input buffer(CI)...")))
  2087 			#ifdef __CI_HEADERS__
  2088 			TVideoPicture* inputBuff = iCIBuffMgmt->MmvbmGetBufferL(iPictureSize);
  2089 			if ( inputBuff )
  2090 			{
  2091 				buffer = ETrue;
  2092 				iRawInBuffer = inputBuff;
  2093 			}
  2094 			#endif
  2095 		}
  2096 	}
  2097 
  2098 	if ( buffer )
  2099 	{
  2100 		PRINT((_L("CVDecTestEngine::GetInputBufferL(), Got Input buffer")))
  2101 		FillAndSendBufferL();
  2102 	}
  2103 	else
  2104 	{
  2105 		PRINT((_L("CVDecTestEngine::GetInputBufferL(), Couldn't get input buffer ")))
  2106 	}
  2107 
  2108 }
  2109 
  2110 
  2111 
  2112 /* ----------------------------------------------------------------------------
  2113 * Name:       CVDecTestEngine::ReadOneCodedPicture()
  2114 * Purpose:    Read one coded picture into decoder input buffer
  2115 * Note:
  2116 * Parameters: TVideoInputBuffer* aCodedInBuffer
  2117 * Return:     TInt
  2118 * --------------------------------------------------------------------------*/
  2119 TInt CVDecTestEngine::ReadOneCodedPicture(TVideoInputBuffer* aCodedInBuffer)
  2120 {
  2121 	PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, In")))
  2122 	TInt buffLength = iInBuffSize;
  2123 	TBool found = EFalse;
  2124 	TInt pos =0;
  2125 	TUint8* testData =NULL;
  2126 	TInt err = KErrNone;
  2127 
  2128 	//Reads VC1 frame
  2129 	if ( iCodecType == EVC1 )
  2130 	{
  2131 		PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, VC1")))
  2132 		return LoadNextFrameL(aCodedInBuffer);
  2133 	}
  2134 
  2135 	if ( aCodedInBuffer->iData.MaxLength() < buffLength )
  2136 	{
  2137 		err = KErrOverflow;
  2138 		PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Buffer is small, [%d]Byte"),aCodedInBuffer->iData.MaxLength()))
  2139 
  2140 		return err;
  2141 	}
  2142 
  2143 	aCodedInBuffer->iData.SetLength(0);
  2144 
  2145 	//Buffer is not full,  reset size of buffer
  2146 	if ( aCodedInBuffer->iData.Length() < buffLength)
  2147 	{
  2148 		buffLength = aCodedInBuffer->iData.Length();
  2149 	}
  2150 
  2151 	testData = const_cast<TUint8*>(aCodedInBuffer->iData.Ptr());
  2152 
  2153 	TUint8* iReadDataChunkTemp = iReadDataChunk;
  2154 
  2155 	TUint8 byte = 0;
  2156 
  2157 	//Check the length of one coded picture
  2158 	if (iCodecType == EH263)
  2159 	{
  2160 		TBool firstStartCode = EFalse;
  2161 		while (!iInputEnd && !found)
  2162 		{
  2163 			TInt zeroCounter = 0;
  2164 			while ((byte = ReadByteFromFile()) == 0x00 && !iInputEnd)
  2165 			{
  2166 				zeroCounter++;
  2167 				pos++;
  2168 			}
  2169 			pos++;
  2170 			if ((zeroCounter >= 2) && ((byte & 0xFC) == 0x80))
  2171 			{
  2172 				if (!firstStartCode)
  2173 				{
  2174 					firstStartCode = ETrue;
  2175 				}
  2176 				else
  2177 				{
  2178 					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, end of h263 picture found")))
  2179 					found = ETrue;
  2180 				}
  2181 			}
  2182 		}
  2183 		if (iInputEnd)
  2184 		{
  2185 			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, inputEndFound, %d"), pos))
  2186 			pos--;
  2187 		}
  2188 		else
  2189 		{
  2190 			pos -= KScLength;
  2191 		}
  2192 		iReadDataChunk = iReadDataChunkTemp;
  2193 		ReadDataToBuffer(aCodedInBuffer, pos);
  2194 
  2195 	}
  2196 	else if ( iCodecType == EMPEG4 )
  2197 	{
  2198 		TBool firstStartCode = EFalse;
  2199 		while (!iInputEnd && !found)
  2200 		{
  2201 			TInt zeroCounter = 0;
  2202 			while ((byte = ReadByteFromFile()) == 0x00 && !iInputEnd)
  2203 			{
  2204 				zeroCounter++;
  2205 				pos++;
  2206 			}
  2207 			pos++;
  2208 			if ((zeroCounter >= 2) && (byte == 0x01))
  2209 			{
  2210 				byte = ReadByteFromFile();
  2211 
  2212 				pos++;
  2213 				if (byte == 0xB6 && !firstStartCode)
  2214 				{
  2215 					firstStartCode = ETrue;
  2216 				}
  2217 				else if (byte != 0xB1 && firstStartCode)
  2218 				{
  2219 					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, end of mpeg-4 picture found [%d]"), pos-4))
  2220 					found = ETrue;
  2221 				}
  2222 			}
  2223 		}
  2224 		if (iInputEnd)
  2225 		{
  2226 			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, inputEndFound, %d"), pos))
  2227 			pos--;
  2228 		}
  2229 		else
  2230 		{
  2231 			pos -= 4;
  2232 		}
  2233 		iReadDataChunk = iReadDataChunkTemp;
  2234 		ReadDataToBuffer(aCodedInBuffer, pos);
  2235 	}
  2236 	else if ( iCodecType == EVP6 )
  2237 	{
  2238 		TUint dataCount = 0;
  2239 		if (iSentBuffCount == 0)
  2240 		{
  2241 			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, First VP6 frame")))
  2242 			//Read signature and version
  2243 			for (TUint i=0; i<5; i++)
  2244 			{
  2245 				byte = ReadByteFromFile();
  2246 			}
  2247 			TUint32 offset = (TUint32)(ReadByteFromFile())<< 24 | (TUint32)(ReadByteFromFile())<< 16 |
  2248 			(TUint32)(ReadByteFromFile())<< 8 | (TUint32)(ReadByteFromFile());
  2249 
  2250 			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, offset %d"), offset))
  2251 			//Jump data after offset
  2252 			for (TUint i=0; i< offset-9; i++ )
  2253 			{
  2254 				byte = ReadByteFromFile();
  2255 			}
  2256 			dataCount += 9+offset-9;
  2257 			//Read previous tag size
  2258 			for (TUint i=0; i< 4; i++ )
  2259 			{
  2260 				byte = ReadByteFromFile();
  2261 			}
  2262 
  2263 		}
  2264 		if (!iInputEnd)
  2265 		{
  2266 
  2267 			TUint8 tagType = ReadByteFromFile();
  2268 
  2269 			if (!iInputEnd)
  2270 			{
  2271 
  2272 				PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, tagType %d"), tagType))
  2273 				dataCount += 5;
  2274 				while (tagType != 9 && !iInputEnd)
  2275 				{
  2276 					TUint32 a = (TUint32)(ReadByteFromFile());
  2277 					TUint32 b = (TUint32)(ReadByteFromFile());
  2278 					TUint32 c = (TUint32)(ReadByteFromFile());
  2279 					TUint32 dataSize =  (a << 16) | (b << 8) | (c);
  2280 					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, dataSize %d"), dataSize))
  2281 					ReadDataToBuffer(aCodedInBuffer, dataSize+7, ETrue);
  2282 					//Previous offset
  2283 					for (TUint i=0; i< 4; i++ )
  2284 					{
  2285 						byte = ReadByteFromFile();
  2286 					}
  2287 					tagType = ReadByteFromFile();
  2288 					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, tagType %d"), tagType))
  2289 					dataCount += dataSize+15;
  2290 				}
  2291 				if(!iInputEnd){
  2292 				TUint32 a = (TUint32)(ReadByteFromFile());
  2293 				TUint32 b = (TUint32)(ReadByteFromFile());
  2294 				TUint32 c = (TUint32)(ReadByteFromFile());
  2295 				TUint32 dataSize =  (a << 16) | (b << 8) | (c);
  2296 				//Discard timestamp and streamID
  2297 				for (TUint i=0; i< 7; i++ )
  2298 				{
  2299 					byte = ReadByteFromFile();
  2300 				}
  2301 				//Frametype and codec ID
  2302 				byte = ReadByteFromFile();
  2303 				//Read VP6 frame to buffer
  2304 				ReadDataToBuffer(aCodedInBuffer, dataSize-1);
  2305 				PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, VP6 frame size %d"), dataSize))
  2306 				dataCount += dataSize+10;
  2307 				//Read previous tag size
  2308 				for (TUint i=0; i< 4; i++ )
  2309 				{
  2310 					byte = ReadByteFromFile();
  2311 				}
  2312 				}
  2313 				else{
  2314 				PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, unknown tags at the end of vp6 stream, discard")))
  2315 				dataCount = 0;
  2316 				}
  2317 			}
  2318 		}
  2319 		if (iInputEnd)
  2320 		{
  2321 			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, inputEndFound")))
  2322 			//aCodedInBuffer.iData->Zero();
  2323 		}
  2324 		return dataCount;
  2325 	}
  2326 	else if ( iCodecType == EFLV )
  2327 	{
  2328 		// FLV fileformat has 3 first bytes 'FLV'. Detect if file has container.
  2329 		PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, find out bitstream type %d == %d."),iFLVFileType,EFLVNotSet));
  2330 
  2331 
  2332 		if(iFLVFileType == EFLVNotSet)
  2333 		{
  2334 			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, find out bitstream type.")));
  2335 
  2336 			byte = ReadByteFromFile();
  2337 			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, %02x"),byte));
  2338 			TUint8 byte2 = ReadByteFromFile();
  2339 			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, %02x"),byte2));
  2340 			TUint8 byte3 = ReadByteFromFile();
  2341 			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, %02x"),byte3));
  2342 			if ( (byte == 0x46) && (byte2 == 0x4C) && (byte3 == 0x56) )
  2343 			{
  2344 				PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, file with container detected.")));
  2345 				iFLVFileType = EFLVContainer;
  2346 			}
  2347 			else
  2348 			{
  2349 				PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, file raw bitstream detected.")));
  2350 				iFLVFileType = EFLVRaw;
  2351 			}
  2352 			iReadDataChunk = iReadDataChunkTemp;
  2353 		}
  2354 
  2355 		if (iFLVFileType == EFLVContainer)
  2356 		{
  2357 			// FLV frames have 00 00 x2 00 00 8x startcode, parse it.
  2358 			TBool firstStartCode = EFalse;
  2359 			TBool frameHeaderEnd = EFalse;
  2360 			TBool frameHeader = EFalse;
  2361 			while (!iInputEnd && !found)
  2362 			{
  2363 				TInt zeroCounter = 0;
  2364 				while ((byte = ReadByteFromFile()) == 0x00 && !iInputEnd)
  2365 				{
  2366 					zeroCounter++;
  2367 					pos++;
  2368 				}
  2369 				pos++;
  2370 				if ((zeroCounter >= 2) && ((byte & 0xF8) == 0x80) && frameHeaderEnd)
  2371 				{
  2372 					// FLV frames have some bytes in the beginning which needs to be removed
  2373 					if (!frameHeader)
  2374 					{
  2375 						iReadDataChunk = iReadDataChunkTemp;
  2376 						ReadDataToBuffer(aCodedInBuffer, pos-3);
  2377 
  2378 						PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, [%d] bytes of flash video frame header removed."), (iReadDataChunk - iReadDataChunkTemp)));
  2379 						iReadDataChunkTemp = iReadDataChunk;
  2380 						zeroCounter = 0;
  2381 						pos = 0;
  2382 						frameHeader = ETrue;
  2383 					}
  2384 					else if (!firstStartCode)
  2385 					{
  2386 						firstStartCode = ETrue;
  2387 						PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, start of flash video picture found [%d]."), pos-3))
  2388 
  2389 					}
  2390 					else
  2391 					{
  2392 						PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, end of flash video picture found [%d]"), pos-3))
  2393 						found = ETrue;
  2394 					}
  2395 				}
  2396 				else if ((zeroCounter >= 2) && ((byte & 0x03) == 0x02))
  2397 				{
  2398 					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, found frame end code at [%d]"), pos-3))
  2399 
  2400 					frameHeaderEnd = ETrue;
  2401 				}
  2402 				else
  2403 				{
  2404 					frameHeaderEnd = EFalse;
  2405 				}
  2406 			}
  2407 			if (iInputEnd)
  2408 			{
  2409 				PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, inputEndFound, %d"), pos))
  2410 				pos--;
  2411 
  2412 				// FLV file has four bytes which needs to be removed in the end
  2413 				pos -= 4;
  2414 			}
  2415 			else
  2416 			{
  2417 				// Go back to beginning of start code (3 bytes)
  2418 				pos -= 3;
  2419 				// Go back to beginning of FLV file frame header(16 bytes)
  2420 				pos -= 16;
  2421 			}
  2422 			iReadDataChunk = iReadDataChunkTemp;
  2423 			ReadDataToBuffer(aCodedInBuffer, pos);
  2424 		}
  2425 		// Raw flash bitstream file
  2426 		else
  2427 		{
  2428 			TBool firstStartCode = EFalse;
  2429 			while (!iInputEnd && !found)
  2430 			{
  2431 				TInt zeroCounter = 0;
  2432 				while ((byte = ReadByteFromFile()) == 0x00 && !iInputEnd)
  2433 				{
  2434 					zeroCounter++;
  2435 					pos++;
  2436 				}
  2437 				pos++;
  2438 				if ((zeroCounter >= 2) && ((byte & 0xF8) == 0x80))
  2439 				{
  2440 					if (!firstStartCode)
  2441 					{
  2442 						firstStartCode = ETrue;
  2443 					}
  2444 					else
  2445 					{
  2446 						PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, end of flash video picture found [%d]"), pos-3))
  2447 
  2448 						found = ETrue;
  2449 					}
  2450 				}
  2451 			}
  2452 			if (iInputEnd)
  2453 			{
  2454 				PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, inputEndFound, %d"), pos))
  2455 				pos--;
  2456 			}
  2457 			else
  2458 			{
  2459 				pos -= 3;
  2460 			}
  2461 			iReadDataChunk = iReadDataChunkTemp;
  2462 			ReadDataToBuffer(aCodedInBuffer, pos);
  2463 		}
  2464 	}
  2465 	else if ( iCodecType == EAVC )
  2466 	{
  2467 		if (iSetAUFormat)
  2468 		{
  2469 			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, AU format case")))
  2470 			TBool auFound = EFalse;
  2471 			TBool firstMB = EFalse;
  2472 			TUint32 nalUnits = 0;
  2473 			TUint32 totalData = 0;
  2474 			iNalOffsetArray = new TUint32[KMaxNumberOfNals];
  2475 			iNalLengthArray = new TUint32[KMaxNumberOfNals];
  2476 			iMemAlloc += 2;
  2477 			TInt previousNal = 0;
  2478 			while (!auFound)
  2479 			{
  2480 				TBool firstStartCode = EFalse;
  2481 				// Check if start code of Visual Object Sequence
  2482 				pos = 0;
  2483 				TInt nalStart = 0;
  2484 				while (!iInputEnd && !found && !auFound)
  2485 				{
  2486 					TInt zeroCounter = 0;
  2487 					while ((byte = ReadByteFromFile()) == 0x00 && !iInputEnd)
  2488 					{
  2489 						zeroCounter++;
  2490 						pos++;
  2491 					}
  2492 					pos++;
  2493 					if ((zeroCounter >= 2) && (byte  == 0x01))
  2494 					{
  2495 						if (!firstStartCode)
  2496 						{
  2497 							firstStartCode = ETrue;
  2498 							nalStart = pos - KScLength;
  2499 							iNalOffsetArray[nalUnits] = pos+totalData;
  2500 
  2501 							byte = ReadByteFromFile();
  2502 							pos++;
  2503 
  2504 							if (((byte & 0x1F) == 7) && ( previousNal == 5 || previousNal == 1 ) )
  2505 							{
  2506 								auFound = ETrue;
  2507 								pos -= 4;
  2508 								GoBackInFile(4);
  2509 							}
  2510 							else if (((byte & 0x1F) == 5) || ((byte & 0x1F) == 1))
  2511 							{
  2512 								byte = ReadByteFromFile();
  2513 								pos++;
  2514 								if (byte >= 128)
  2515 								{
  2516 									if (firstMB)
  2517 									{
  2518 										//NAL that belongs to the next AU
  2519 										PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Next AU Nal Found")))
  2520 										auFound = ETrue;
  2521 										pos -= 5;
  2522 										GoBackInFile(5);
  2523 									}
  2524 									else
  2525 									{
  2526 										PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, First MB")))
  2527 										firstMB = ETrue;
  2528 									}
  2529 								}
  2530 							}
  2531 							previousNal = byte & 0x1F;
  2532 
  2533 						}
  2534 						else
  2535 						{
  2536 							PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, NAL start: [%d]"), nalStart ))
  2537 							PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, end of h264 NAL found at [%d]"), pos ))
  2538 
  2539 							found = ETrue;
  2540 							pos -= KScLength;
  2541 							GoBackInFile(KScLength); //go back before next start code
  2542 						}
  2543 					}
  2544 				}
  2545 
  2546 				if (!found && iInputEnd)
  2547 				{
  2548 					auFound = ETrue;
  2549 					if ( nalUnits == 0 )
  2550 					{
  2551 						totalData = pos;
  2552 						PRINT((_L("CVDecTestEngine::ReadOneCodedPicture: pos: %d"),pos))
  2553 						iNalLengthArray[nalUnits] = pos;
  2554 						nalUnits++;
  2555 					}
  2556 				}
  2557 				found = EFalse;
  2558 				if (!auFound)
  2559 				{
  2560 					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Searching next NAL")))
  2561 					totalData += pos;
  2562 					iNalLengthArray[nalUnits] = pos - 3 - nalStart;
  2563 					nalUnits++;
  2564 				}
  2565 				else
  2566 				{
  2567 					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, AU Found")))
  2568 					iReadDataChunk = iReadDataChunkTemp;
  2569 					ReadDataToBuffer(aCodedInBuffer, totalData);
  2570 					pos = totalData; //Set amount of data read from a file
  2571 					//Optional filler data to align the header at a 32-bit boundary
  2572 					while ((totalData % 4) != 0)
  2573 					{
  2574 						testData[totalData] = 0;
  2575 						totalData++;
  2576 					}
  2577 					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Casting headerpointer")))
  2578 					TUint8* headerData = reinterpret_cast<TUint8*>(const_cast<TUint8*>(aCodedInBuffer->iData.Ptr()));
  2579 					TUint headerStart = totalData; //changing 8bit index to 32bit
  2580 					for (TUint i = 0; i < nalUnits; i++)
  2581 					{
  2582 						*((TUint32*)&headerData[headerStart]) = static_cast<TUint32>(iNalOffsetArray[i]);
  2583 						PRINT((_L("CVDecTestEngine::ReadOneCodedPicture: offset [%d] | [%d] "), iNalOffsetArray[i], headerData[headerStart]))
  2584 						*((TUint32*)&headerData[headerStart+4]) = static_cast<TUint32>(iNalLengthArray[i]);
  2585 						PRINT((_L("CVDecTestEngine::ReadOneCodedPicture: size [%d] | [%d][%d][%d][%d] "), iNalLengthArray[i], headerData[headerStart+4],headerData[headerStart+5],headerData[headerStart+6],headerData[headerStart+7]))
  2586 						headerStart += 8;
  2587 					}
  2588 					*((TUint32*)&headerData[headerStart]) = static_cast<TUint32>(nalUnits);
  2589 					headerStart += 4;
  2590 					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, deleting arrays")))
  2591 					delete iNalLengthArray;
  2592 					iNalLengthArray = NULL;
  2593 					iMemDelete++;
  2594 					delete iNalOffsetArray;
  2595 					iNalOffsetArray = NULL;
  2596 					iMemDelete++;
  2597 					#ifdef __MEM_CHECK_
  2598 					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, mem del, iNalLengthArray") ))
  2599 					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, mem del, iNalOffsetArray") ))
  2600 					#endif
  2601 
  2602 					/*for (TUint i = 0; i < 100; i++)
  2603 					{
  2604 					PRINT((_L("test data End [%d]"), testData[pos-100+i]))
  2605 					} */
  2606 
  2607 					//Set Size to length of the header + one picure, and reset position to be read next time
  2608 					aCodedInBuffer->iData.SetLength(headerStart);
  2609 					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture,length of frame: [%d] "),pos))
  2610 					//TInt tempLength = pos - buffLength;
  2611 					//err = iInFile.Seek(ESeekCurrent,tempLength);
  2612 					return pos;
  2613 				}
  2614 			}
  2615 		}
  2616 		else
  2617 		{
  2618 			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Bytestream case")))
  2619 			TBool auFound = EFalse;
  2620 			TBool firstMB = EFalse;
  2621 			TUint32 totalData = 0;
  2622 			TInt previousNal = 0;
  2623 			while (!auFound)
  2624 			{
  2625 				// Check if start code of Visual Object Sequence
  2626 				TBool firstStartCode = EFalse;
  2627 				pos = 0;
  2628 				TInt nalStart = 0;
  2629 				while (!iInputEnd && !found)
  2630 				{
  2631 					TInt zeroCounter = 0;
  2632 					while ((byte = ReadByteFromFile()) == 0x00 && !iInputEnd)
  2633 					{
  2634 						zeroCounter++;
  2635 						pos++;
  2636 					}
  2637 					pos++;
  2638 					if ((zeroCounter >= 2) && (byte  == 0x01))
  2639 					{
  2640 						if (!firstStartCode)
  2641 						{
  2642 							firstStartCode = ETrue;
  2643 							nalStart = pos-KScLength;
  2644 							byte = ReadByteFromFile();
  2645 							pos++;
  2646 
  2647 							if (((byte & 0x1F) == 7) && ( previousNal == 5 || previousNal == 1 ) )
  2648 							{
  2649 								auFound = ETrue;
  2650 								pos -= 4;
  2651 								GoBackInFile(4);
  2652 							}
  2653 							else if (((byte & 0x1F) == 5) || ((byte & 0x1F) == 1))
  2654 							{
  2655 								byte = ReadByteFromFile();
  2656 								pos++;
  2657 								if (byte >= 128)
  2658 								{
  2659 									if (firstMB)
  2660 									{
  2661 										//NAL that belongs to the next AU
  2662 										PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Next AU Nal Found")))
  2663 										auFound = ETrue;
  2664 										pos -= 5;
  2665 										GoBackInFile(5);
  2666 									}
  2667 									else
  2668 									{
  2669 										PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, First MB")))
  2670 										firstMB = ETrue;
  2671 									}
  2672 								}
  2673 							}
  2674 							previousNal = byte & 0x1F;
  2675 
  2676 						}
  2677 						else
  2678 						{
  2679 							PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, NAL start: [%d]"), nalStart ))
  2680 							PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, end of h264 NAL found at [%d]"), pos ))
  2681 							found = ETrue;
  2682 							pos -= KScLength;
  2683 							GoBackInFile(KScLength); //go back before next start code
  2684 						}
  2685 					}
  2686 				}
  2687 
  2688 				if (!found && iInputEnd)
  2689 				{
  2690 					totalData += pos;
  2691 					auFound = ETrue;
  2692 				}
  2693 				found = EFalse;
  2694 				if (!auFound)
  2695 				{
  2696 					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Searching next NAL")))
  2697 					totalData += pos;
  2698 				}
  2699 				else
  2700 				{
  2701 					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, AU Found")))
  2702 					iReadDataChunk = iReadDataChunkTemp;
  2703 					ReadDataToBuffer(aCodedInBuffer, totalData);
  2704 					pos = totalData; //Set amount of data read from a file
  2705 					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture,length of frame: [%d] "),pos));
  2706 					return pos;
  2707 				}
  2708 			}
  2709 
  2710 		}
  2711 	}
  2712 	else
  2713 	{
  2714 		err = KErrNotSupported;
  2715 		PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, codec type unknown")))
  2716 	}
  2717 
  2718 	if (err == KErrNone)  // wk45 for listing frame size
  2719 	err = pos;
  2720 
  2721 	PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Out")))
  2722 	return err;
  2723 }
  2724 
  2725 /* ----------------------------------------------------------------------------
  2726 * Name:       CVDecTestEngine::ReadOneCodedPicture()
  2727 * Purpose:    Read one coded picture into decoder input buffer, frame size is known
  2728 * Note:
  2729 * Parameters: TVideoInputBuffer* aCodedInBuffer TInt Size
  2730 * Return:     TInt
  2731 * --------------------------------------------------------------------------*/
  2732 
  2733 TInt CVDecTestEngine::ReadOneCodedPicture(TVideoInputBuffer* aCodedInBuffer, TInt aSize)
  2734 {
  2735 	TInt err = KErrNone;
  2736 
  2737 	err = iInFile.Read(aCodedInBuffer->iData, aSize);
  2738 	PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Frame Size"),aSize ))
  2739 
  2740 	if (err == KErrNone)
  2741 	{
  2742 		err = aSize;
  2743 	}
  2744 
  2745 	if (aSize == 0)
  2746 	{
  2747 		iInputEnd = ETrue;
  2748 	}
  2749 
  2750 	return err;
  2751 }
  2752 
  2753 
  2754 
  2755 /* ----------------------------------------------------------------------------
  2756 * Name:       CVDecTestEngine::ReadRawPicture()
  2757 * Purpose:    Read one raw picture into postprocessor input buffer
  2758 * Note:
  2759 * Parameters: None
  2760 * Return:     None
  2761 * --------------------------------------------------------------------------*/
  2762 
  2763 
  2764 TInt CVDecTestEngine::ReadRawPicture()
  2765 {
  2766 	TInt err = KErrNone;
  2767 
  2768 	PRINT((_L("CVDecTestEngine::ReadRawPicture, Maximum data length in video picture: [%d]"),iRawInBuffer->iData.iRawData->MaxLength()))
  2769 	iRawInBuffer->iData.iRawData->Set((TUint8*)iRawInBuffer->iData.iRawData->Ptr(), 0, iInBuffSize);
  2770 
  2771 
  2772 	err = iInFile.Read(*(iRawInBuffer->iData.iRawData),iInBuffSize);
  2773 	PRINT((_L("CVDecTestEngine::ReadRawPicture, data length:[%d]"),iRawInBuffer->iData.iRawData->Length()))
  2774 
  2775 	if ( !err )
  2776 	{
  2777 		if ( (iRawInBuffer->iData.iRawData->Length()) == 0)
  2778 		{
  2779 			iInputEnd = ETrue;
  2780 		}
  2781 	}
  2782 
  2783 	PRINT((_L("CVDecTestEngine::ReadRawPicture, Out error:[%d]"),err))
  2784 	return err;
  2785 
  2786 }
  2787 
  2788 /* ----------------------------------------------------------------------------
  2789 * Name:       CVDecTestEngine::GetReturnedPictureL
  2790 * Purpose:    Retrieve output picuture
  2791 * Note:       Memory buffer output is used
  2792 * Parameters: None
  2793 * Return:     None
  2794 * --------------------------------------------------------------------------*/
  2795 
  2796 
  2797 void CVDecTestEngine::GetReturnedPictureL()
  2798 {
  2799 	PRINT((_L("CVDecTestEngine::GetReturnedPictureL, In")))
  2800 	iOutBuffer = iDevvp->NextPictureL();
  2801 
  2802 	if ( iOutBuffer )
  2803 	{
  2804 		PRINT((_L("CVDecTestEngine::GetReturnedPictureL, data Size in Byte:[%d]"),iOutBuffer->iData.iRawData->Size() ))
  2805 		iReturnedBuffCount++;
  2806 		SaveAndReturnPicture();
  2807 	}
  2808 	PRINT((_L("CVDecTestEngine::GetReturnedPictureL, Out")))
  2809 }
  2810 
  2811 
  2812 /* ----------------------------------------------------------------------------
  2813 * Name:       CVDecTestEngine::SaveAndReturnPicture()
  2814 * Purpose:    Store output data into a file
  2815 * Note:       Memory buffer output is used
  2816 * Parameters: None
  2817 * Return:     None
  2818 * --------------------------------------------------------------------------*/
  2819 
  2820 void CVDecTestEngine::SaveAndReturnPicture()
  2821 {
  2822 	PRINT((_L("CVDecTestEngine::SaveAndReturnPicture, In")))
  2823 	TInt err = KErrNone;
  2824 
  2825 	if (iFrameMeasurement && iReturnedBuffCount == 1)
  2826 	{
  2827 		iClock->Reset(); // Reset Timer
  2828 		PRINT((_L("CVDecTestEngine::SaveAndReturnPicture, clock reset")))
  2829 	}
  2830 	else
  2831 	{
  2832 		if ( iFrameMeasurement )
  2833 		{
  2834 			PRINT((_L("CVDecTestEngine::SaveAndReturnPicture, Frame measurement is on, %d. frame"), iReturnedBuffCount))
  2835 			TTimeIntervalMicroSeconds time;
  2836 			time = iClock->Time();
  2837 			PRINT((_L("CVDecTestEngine::SaveAndReturnPicture, time measured: [%d%d]"), I64HIGH(time.Int64()), I64LOW(time.Int64())))
  2838 			iFrameTime = (TReal)time.Int64()/1000000.0;
  2839 			if(iInstantFpsEnabled)
  2840 			{
  2841 				iInstantFpsList.Append(time);
  2842 			}
  2843 
  2844 		}
  2845 		else
  2846 		{
  2847 			err = iOutFile.Write(*(iOutBuffer->iData.iRawData),iOutBuffer->iData.iRawData->Size() );
  2848 			PRINT((_L("CVDecTestEngine::SaveAndReturnPicture,  Output data stored: count[%d]"),iReturnedBuffCount))
  2849 
  2850 
  2851 		}
  2852 	}
  2853 
  2854 	if (iSetSlowClient)
  2855 	{
  2856 		if (iOutBufferTemp)
  2857 		{
  2858 			PRINT((_L("CVDecTestEngine::SaveAndReturnPicture, returning previous buffer (slow client)")))
  2859 
  2860 			iDevvp->ReturnPicture(iOutBufferTemp);
  2861 		}
  2862 		iOutBufferTemp = iOutBuffer;
  2863 	}
  2864 	else
  2865 	{
  2866 		PRINT((_L("CVDecTestEngine::SaveAndReturnPicture, returning buffer")))
  2867 		iDevvp->ReturnPicture(iOutBuffer);
  2868 	}
  2869 
  2870 
  2871 	iOutBuffer = NULL;
  2872 
  2873 	if ( err != KErrNone )
  2874 	{
  2875 		//iInputEnd = ETrue; Fix for MRII-7HW9R3
  2876 		iError = err;
  2877 		PRINT((_L("CVDecTestEngine::SaveAndReturnPicture, Error in store data: [%d]"),iError))
  2878 	}
  2879 
  2880 	PRINT((_L("CVDecTestEngine::SaveAndReturnPicture, Out")))
  2881 }
  2882 
  2883 
  2884 
  2885 /* ----------------------------------------------------------------------------
  2886 * Name:       CVDecTestEngine::Pause()
  2887 * Purpose:    Pause decoding/postprocessing
  2888 * Note:
  2889 * Parameters: None
  2890 * Return:     None
  2891 * --------------------------------------------------------------------------*/
  2892 
  2893 
  2894 TInt CVDecTestEngine::Pause()
  2895 {
  2896 	TInt err = KErrNone;
  2897 
  2898 	if ( iState == ERunning )
  2899 	{
  2900 		if ( iSynchronized )
  2901 		{
  2902 			iClock->Suspend();  //Stop Clock source
  2903 		}
  2904 		iDevvp->Pause();
  2905 		iState = EPaused;
  2906 		PRINT((_L("CVDecTestEngine::Pause(), Paused")))
  2907 	}
  2908 	else
  2909 	{
  2910 		err = KErrGeneral;
  2911 	}
  2912 	return err;
  2913 }
  2914 
  2915 
  2916 /* ----------------------------------------------------------------------------
  2917 * Name:       CVDecTestEngine::Resume()
  2918 * Purpose:    Resume decoding/postprocessing
  2919 * Note:
  2920 * Parameters: None
  2921 * Return:     None
  2922 * --------------------------------------------------------------------------*/
  2923 
  2924 TInt CVDecTestEngine::Resume()
  2925 {
  2926 
  2927 	TInt err = KErrNone;
  2928 
  2929 	if ( iState == EPaused )
  2930 	{
  2931 		if ( iSynchronized )
  2932 		{
  2933 			iClock->Resume();  //Restart Clock source
  2934 		}
  2935 		iDevvp->Resume();
  2936 		iState = ERunning;
  2937 		PRINT((_L("CVDecTestEngine::Resume(), Resumed")))
  2938 
  2939 		/*if ( iDecHWDevId )
  2940 		{
  2941 		if ( iDevvp->NumFreeBuffers() )
  2942 		{
  2943 		iDecTestAO->RequestData();   //Restart data transfer
  2944 		}
  2945 		else
  2946 		{
  2947 		PRINT((_L("CVDecTestEngine::Resume, No input buffer available now")));
  2948 		}
  2949 		}*/
  2950 		iDecTestAO->RequestData();
  2951 	}
  2952 	else
  2953 	{
  2954 		err = KErrGeneral;
  2955 	}
  2956 
  2957 	return err;
  2958 }
  2959 
  2960 
  2961 /* ----------------------------------------------------------------------------
  2962 * Name:       CVDecTestEngine::FreezePicture()
  2963 * Purpose:    Freeze decoding/postprocessing
  2964 * Note:
  2965 * Parameters: TTimeIntervalMicroSeconds aTimeStamp
  2966 * Return:     None
  2967 * --------------------------------------------------------------------------*/
  2968 
  2969 void CVDecTestEngine::FreezePicture(TTimeIntervalMicroSeconds aTimeStamp)
  2970 {
  2971 	iDevvp->FreezePicture(aTimeStamp);
  2972 	PRINT((_L("CVDecTestEngine::Freeze(), Freezed: timestamp[%ld]"), aTimeStamp.Int64()))
  2973 }
  2974 
  2975 
  2976 /* ----------------------------------------------------------------------------
  2977 * Name:       CVDecTestEngine::ReleaseFreeze()
  2978 * Purpose:    Release Freeze
  2979 * Note:
  2980 * Parameters: TTimeIntervalMicroSeconds aTimeStamp
  2981 * Return:     None
  2982 * --------------------------------------------------------------------------*/
  2983 
  2984 
  2985 void CVDecTestEngine::ReleaseFreeze(TTimeIntervalMicroSeconds aTimeStamp)
  2986 {
  2987 	iDevvp->ReleaseFreeze(aTimeStamp);
  2988 	PRINT((_L("CVDecTestEngine::ReleaseFreeze(), Freeze released")))
  2989 }
  2990 
  2991 
  2992 /* ----------------------------------------------------------------------------
  2993 * Name:       CVDecTestEngine::StartDirectScreenAccessL
  2994 * Purpose:    Start DirectScreenAccess
  2995 * Note:
  2996 * Parameters: None
  2997 * Return:     None
  2998 * --------------------------------------------------------------------------*/
  2999 
  3000 void CVDecTestEngine::StartDirectScreenAccessL(TRect aVideoRect, TRect aClipRegion)
  3001 {
  3002 	PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL(), In")))
  3003 	if (!iScreenDevice)
  3004 	{
  3005 		User::LeaveIfError (RFbsSession::Connect());
  3006 		PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL, connected to Fbs server :")))
  3007 		TInt err = KErrNone;
  3008 		if( iUseSecondScreen )
  3009 		{
  3010 			TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(1, EColor16MU));
  3011 		}
  3012 		else
  3013 		{
  3014 			TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(0, EColor16MU));
  3015 		}
  3016 		if( err == KErrNotSupported )
  3017 		{
  3018 			PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL, EColor16MU is not supported, ")))
  3019 			if( iUseSecondScreen )
  3020 			{
  3021 				TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(1, EColor16MA));
  3022 			}
  3023 			else
  3024 			{
  3025 				TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(0, EColor16MA));
  3026 			}
  3027 		}
  3028 
  3029 		if( err != KErrNone )
  3030 		{
  3031 			PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL, couldn't initialize screen device, err[%d]"),err))
  3032 		}
  3033 
  3034 		else
  3035 		{
  3036 			iMemAlloc++;
  3037 			#ifdef __MEM_CHECK_
  3038 			PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL, mem alloc, iScreenDevice") ))
  3039 			#endif
  3040 		}
  3041 	}
  3042 
  3043 	TRegionFix<1> region(aClipRegion);
  3044 
  3045 	//Start DSA
  3046 	iDevvp->StartDirectScreenAccessL(aVideoRect, *iScreenDevice, region);
  3047 	PRINT((_L("CVDecTestEngine::Start, DSA started")))
  3048 	iDsaStarted = ETrue;
  3049 
  3050 	PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL(), Out")))
  3051 }
  3052 
  3053 /* ----------------------------------------------------------------------------
  3054 * Name:       CVDecTestEngine::StartDirectScreenAccessL
  3055 * Purpose:    Start DirectScreenAccess
  3056 * Note:
  3057 * Parameters: None
  3058 * Return:     None
  3059 * --------------------------------------------------------------------------*/
  3060 
  3061 void CVDecTestEngine::StartDirectScreenAccessL()
  3062 {
  3063 	PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL(), In")))
  3064 	if (iDsaStarted)
  3065 	{
  3066 		PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL(), DSA already started- abort first")))
  3067 		AbortDirectScreenAccess();
  3068 	}
  3069 
  3070 	if (!iScreenDevice)
  3071 	{
  3072 
  3073 
  3074 		User::LeaveIfError (RFbsSession::Connect());
  3075 		PRINT((_L("CVDecTestEngine::Start, connected to Fbs server :")))
  3076 
  3077 
  3078 		TInt err = KErrNone;
  3079 		if( iUseSecondScreen )
  3080 		{
  3081 			TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(1, EColor16MU));
  3082 		}
  3083 		else
  3084 		{
  3085 			TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(0, EColor16MU));
  3086 		}
  3087 		//TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(0, EColor16MU));
  3088 		if( err == KErrNotSupported )
  3089 		{
  3090 			PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL, EColor16MU is not supported, ")))
  3091 			if( iUseSecondScreen )
  3092 			{
  3093 				TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(1, EColor16MA));
  3094 			}
  3095 			else
  3096 			{
  3097 				TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(0, EColor16MA));
  3098 			}
  3099 			//TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(0, EColor16MA));
  3100 		}
  3101 
  3102 		if ( err != KErrNone )
  3103 		{
  3104 			PRINT((_L("CVDecTestEngine::Start, couldn't initialize screen device, err[%d]"),err))
  3105 		}
  3106 	}
  3107 
  3108 
  3109 
  3110 	PRINT((_L("CVDecTestEngine::Start, disprect x[%d],y[%d] "),iDispRect.iTl.iX, iDispRect.iTl.iY))
  3111 	PRINT((_L("CVDecTestEngine::Start, disprect width[%d],height[%d] "),iDispRect.Width(),iDispRect.Height()))
  3112 
  3113 
  3114 	TRegionFix<1> region(iDispRect);
  3115 
  3116 	//Start DSA
  3117 	iDevvp->StartDirectScreenAccessL(iDispRect, *iScreenDevice, region);
  3118 	PRINT((_L("CVDecTestEngine::Start, DSA started")))
  3119 	iDsaStarted = ETrue;
  3120 
  3121 
  3122 	PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL(), Out")))
  3123 }
  3124 
  3125 /* ----------------------------------------------------------------------------
  3126 * Name:       CVDecTestEngine::AbortDirectScreenAccess
  3127 * Purpose:    AbortDirectScreenAccess
  3128 * Note:
  3129 * Parameters: None
  3130 * Return:     None
  3131 * --------------------------------------------------------------------------*/
  3132 
  3133 void CVDecTestEngine::AbortDirectScreenAccess()
  3134 {
  3135 	if ( iDirectScreenAccess && iDsaStarted )
  3136 	{
  3137 	iDevvp->AbortDirectScreenAccess();
  3138 	iDsaStarted = EFalse;
  3139 	PRINT((_L("CVDecTestEngine::AbortDirectScreenAccess, aborted ")))
  3140 	}
  3141 }
  3142 
  3143 /* ----------------------------------------------------------------------------
  3144 * Name:       CVDecTestEngine::SetSecureOutputL
  3145 * Purpose:    Set sucure output enable
  3146 * Note:
  3147 * Parameters: TBool aSecure
  3148 * Return:     None
  3149 * --------------------------------------------------------------------------*/
  3150 
  3151 
  3152 void CVDecTestEngine::SetSecureOutputL(TBool aSecure)
  3153 {
  3154 	PRINT((_L("CVDecTestEngine::SetSecureOutputL, In")))
  3155 
  3156 	#ifdef __SECUREOUTPUTCI__
  3157 
  3158 	MMmfVideoSecureOutput* secureOutput = NULL;     // Custom interface Secure output
  3159 
  3160 	secureOutput = (MMmfVideoSecureOutput*)iDevvp->CustomInterface(iPostProcId, KMmfVideoSecureOutputUid);
  3161 
  3162 	if (!secureOutput)
  3163 	{
  3164 		PRINT((_L("CVDecTestEngine::SetSecureOutput, Failed to retrieve Secure CI")))
  3165 		User::Leave(KErrGeneral);
  3166 	}
  3167 
  3168 	secureOutput->MmvsoSetSecureOutputL(aSecure);
  3169 
  3170 	#endif
  3171 
  3172 	PRINT((_L("CVDecTestEngine::SetSecureOutputL, Out [%d]"), aSecure))
  3173 }
  3174 
  3175 /* ----------------------------------------------------------------------------
  3176 * Name:       CVDecTestEngine::SetPosition
  3177 * Purpose:    Set postion
  3178 * Note:
  3179 * Parameters: TTimeIntervalMicroSeconds aTimeStamp
  3180 * Return:     None
  3181 * --------------------------------------------------------------------------*/
  3182 
  3183 
  3184 void CVDecTestEngine::SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition)
  3185 {
  3186 	PRINT((_L("CVDecTestEngine::SetPosition, In")))
  3187 
  3188 	iDevvp->SetPosition(aPlaybackPosition);
  3189 
  3190 	PRINT((_L("CVDecTestEngine::SetPosition, Out")))
  3191 }
  3192 
  3193 /* ----------------------------------------------------------------------------
  3194 * Name:       CVDecTestEngine::ResetPosition
  3195 * Purpose:    Reset postion to start
  3196 * Note:
  3197 * Parameters: TTimeIntervalMicroSeconds aTimeStamp
  3198 * Return:     None
  3199 * --------------------------------------------------------------------------*/
  3200 
  3201 
  3202 void CVDecTestEngine::ResetPosition()
  3203 {
  3204 	PRINT((_L("CVDecTestEngine::ResetPosition, In")))
  3205 	TTimeIntervalMicroSeconds starttime(0);
  3206 
  3207 	iDevvp->SetPosition(starttime);
  3208 	PRINT((_L("CVDecTestEngine::ResetPosition, Reset Position to start of bitstream")))
  3209 
  3210 	if ( iSynchronized )
  3211 	{
  3212 		iClock->Reset(starttime);
  3213 		iTimeStamp = 0;
  3214 		TTimeIntervalMicroSeconds currenttime = iClock->Time();
  3215 		PRINT((_L("CVDecTestEngine::ResetPosition, current time[%ld]"),currenttime.Int64() ))
  3216 	}
  3217 	TInt pos = 0;
  3218 	iInFile.Seek(ESeekStart,pos);
  3219 	iSentBuffCount = 0;
  3220 
  3221 	PRINT((_L("CVDecTestEngine::ResetPosition, In")))
  3222 }
  3223 
  3224 
  3225 
  3226 
  3227 /* ----------------------------------------------------------------------------
  3228 * Name:       CVDecTestEngine::PlaybackPosition
  3229 * Purpose:    Ritrieve Playback Position
  3230 * Note:
  3231 * Parameters: None
  3232 * Return:     None
  3233 * --------------------------------------------------------------------------*/
  3234 
  3235 
  3236 TTimeIntervalMicroSeconds CVDecTestEngine::PlaybackPosition()
  3237 {
  3238 	PRINT((_L("CVDecTestEngine::PlaybackPosition, In")))
  3239 
  3240 	TTimeIntervalMicroSeconds position = iDevvp->PlaybackPosition();
  3241 	PRINT((_L("CVDecTestEngine::PlaybackPosition, Playback Position[%ld]"),position.Int64()))
  3242 
  3243 	PRINT((_L("CVDecTestEngine::PlaybackPosition, Out")))
  3244 	return position;
  3245 }
  3246 
  3247 
  3248 /* ----------------------------------------------------------------------------
  3249 * Name:       CVDecTestEngine::DecodingPosition
  3250 * Purpose:    Ritrieve Decoding Position
  3251 * Note:
  3252 * Parameters: None
  3253 * Return:     None
  3254 * --------------------------------------------------------------------------*/
  3255 
  3256 
  3257 void CVDecTestEngine::DecodingPosition()
  3258 {
  3259 	PRINT((_L("CVDecTestEngine::DecodingPosition, In")))
  3260 
  3261 	TTimeIntervalMicroSeconds position = iDevvp->DecodingPosition();
  3262 	PRINT((_L("CVDecTestEngine::DecodingPosition, Decoding Position[%ld]"),position.Int64()))
  3263 
  3264 	PRINT((_L("CVDecTestEngine::DecodingPosition, Out")))
  3265 }
  3266 
  3267 /* ----------------------------------------------------------------------------
  3268 * Name:       CVDecTestEngine::GetFrameSizeCount
  3269 * Purpose:    Get frame size count after frame sizes are listed
  3270 * Note:       Called after initialization
  3271 * Parameters: None
  3272 * Return:     TInt
  3273 * --------------------------------------------------------------------------*/
  3274 TInt CVDecTestEngine::GetFrameSizeCount()
  3275     {
  3276     return iFrameSizeList.Count();
  3277     }
  3278 
  3279 /* ----------------------------------------------------------------------------
  3280 * Name:       CVDecTestEngine::EnableSynchronization
  3281 * Purpose:    Set Clock and enable synchronization
  3282 * Note:       Called before initialization and after Decoder/post-processor selected
  3283 * Parameters: TInt aFrameRate
  3284 * Return:     None
  3285 * --------------------------------------------------------------------------*/
  3286 
  3287 void CVDecTestEngine::EnableSynchronization(TInt aFrameRate)
  3288 {
  3289 	PRINT((_L("CVDecTestEngine::EnableSynchronization, In")))
  3290 
  3291 	iDevvp->SetClockSource(iClock);
  3292 	PRINT((_L("CVDecTestEngine::Synchronization, Clock source set")))
  3293 
  3294 	iSynchronized = ETrue;
  3295 	iFrameTimeInterval = (TInt64)(1000000/aFrameRate);
  3296 	PRINT((_L("CVDecTestEngine::Synchronization, Frame rate:[%d]"),aFrameRate ))
  3297 
  3298 	PRINT((_L("CVDecTestEngine::EnableSynchronization, Out")))
  3299 }
  3300 
  3301 
  3302 /* ----------------------------------------------------------------------------
  3303 * Name:       CVDecTestEngine::SetWindowRect
  3304 * Purpose:    Set sucure output enable
  3305 * Note:
  3306 * Parameters: TInt aX, TInt aY, TSize aSize
  3307 * Return:     None
  3308 * --------------------------------------------------------------------------*/
  3309 
  3310 void CVDecTestEngine::SetWindowRect(TInt aX, TInt aY, TSize aSize )
  3311 {
  3312 
  3313 	iDispRect.SetRect(TPoint(aX,aY),aSize);
  3314 
  3315 	PRINT((_L("CVDecTestEngine::SetWindowRect, [%d], [%d]"),aX ,aY ))
  3316 	PRINT((_L("CVDecTestEngine::SetWindowRect, width[%d], height[%d]"),aSize.iWidth, aSize.iHeight))
  3317 }
  3318 
  3319 
  3320 /* ----------------------------------------------------------------------------
  3321 * Name:       CVDecTestEngine::ListFrameSizeL
  3322 * Purpose:    List size of each frmae of coded bitstream for synchrinized
  3323 *             playback
  3324 * Note:
  3325 * Parameters: None
  3326 * Return:     None
  3327 * --------------------------------------------------------------------------*/
  3328 
  3329 void CVDecTestEngine::ListFrameSizeL(RArray<TInt> aFramesizes)
  3330 {
  3331 
  3332 	if ( iCodecType == EVC1 ){
  3333 
  3334 		PRINT((_L("CVDecTestEngine::ListFrameSizeL, not supported for VC1") ))
  3335 		User::Leave(KErrGeneral);
  3336 	}
  3337 
  3338 	TInt framesize = 0;
  3339 	TVideoInputBuffer* videoBuffer = new(ELeave) TVideoInputBuffer;
  3340 	iMemAlloc++;
  3341 	HBufC8* tempBuff = HBufC8::NewL(iInBuffSize);
  3342 	iMemAlloc++;
  3343 	#ifdef __MEM_CHECK_
  3344 	PRINT((_L("CVDecTestEngine::ListFrameSizeL, mem alloc, videoBuffer & iInBuffSize") ))
  3345 	#endif
  3346 	videoBuffer->iData.Set(tempBuff->Des());
  3347 	//iListFrameSize = ETrue;
  3348 
  3349 	if(aFramesizes.Count() > 0)
  3350 	{
  3351 		for (TUint i = 0; i < aFramesizes.Count(); i++)
  3352 		{
  3353 			iFrameSizeList.AppendL(aFramesizes[i]);
  3354 			PRINT((_L("CVDecTestEngine::ListFrameSize, user input [%d]"),aFramesizes[i]))
  3355 		}
  3356 
  3357 	}
  3358 	else
  3359 	{
  3360 		while (!iInputEnd)
  3361 		{
  3362 			videoBuffer->iData.SetLength(0);
  3363 			framesize = ReadOneCodedPicture(videoBuffer);
  3364 			PRINT((_L("CVDecTestEngine::ListFrameSize, frame size[%d]"),framesize))
  3365 			// here append frame size in list
  3366 
  3367 			if (framesize >= 0 )
  3368 			{
  3369 				iFrameSizeList.AppendL(framesize);
  3370 				iSentBuffCount++;
  3371 			}
  3372 			else
  3373 			{
  3374 				break;
  3375 			}
  3376 
  3377 		}
  3378 	}
  3379 	PRINT((_L("CVDecTestEngine::ListFrameSize, frame count[%d]"),iFrameSizeList.Count()))
  3380 
  3381 	// cleanup
  3382 	//Reset file postion to start
  3383 	TInt pos =0;
  3384 	iSentBuffCount = 0;
  3385 	iReadDataChunk = iDataChunk;
  3386 	iWriteDataChunk = iDataChunk;
  3387 	iDataReadFromFile = 0;
  3388 	iInFile.Seek(ESeekStart,pos);
  3389 
  3390 	iInputEnd = EFalse;
  3391 
  3392 	delete tempBuff;
  3393 	delete videoBuffer;
  3394 	iMemDelete += 2;
  3395 	#ifdef __MEM_CHECK_
  3396 	PRINT((_L("CVDecTestEngine::ListFrameSize, mem del, tempBuff & videoBuffer") ))
  3397 	#endif
  3398 	if ( framesize < 0)
  3399 	{
  3400         PRINT((_L("CVDecTestEngine::ListFrameSize, error[%d]"),framesize ))
  3401 		User::Leave(framesize);
  3402 	}
  3403 
  3404 }
  3405 
  3406 
  3407 /* ----------------------------------------------------------------------------
  3408 * Name:       CVDecTestEngine::SetLandscapeMode()
  3409 * Purpose:    Set landscape mode flag
  3410 * Note:
  3411 * Parameters: None
  3412 * Return:     None
  3413 * --------------------------------------------------------------------------*/
  3414 
  3415 /*
  3416 void CVDecTestEngine::SetLandscapeMode()
  3417 {
  3418 
  3419 iLandscapeMode = ETrue;
  3420 PRINT((_L("CVDecTestEngine::SetLandscapeMode, Landscape mode is set") ))
  3421 
  3422 }
  3423 */
  3424 
  3425 /* ----------------------------------------------------------------------------
  3426 * Name:       CVDecTestEngine::SelectDecoderL()
  3427 * Purpose:
  3428 * Note:
  3429 * Parameters: None
  3430 * Return:     None
  3431 * --------------------------------------------------------------------------*/
  3432 void CVDecTestEngine::SelectDecoderL(const TUid& aUid)
  3433 {
  3434 	PRINT((_L("CVDecTestEngine::SelectDecoderL, In") ))
  3435 
  3436 	iDecoderUid = aUid;
  3437 	iDecHWDevId = iDevvp->SelectDecoderL(aUid);
  3438 
  3439 	#ifdef __RESOURCENOTIFICATION__
  3440 	MMmfVideoResourceHandler* handler = (MMmfVideoResourceHandler*)iDevvp->CustomInterface(iDecHWDevId, KUidMmfVideoResourceManagement );
  3441 	handler->MmvrhSetObserver(((MMmfVideoResourceObserver*)(this)));
  3442 	#endif
  3443 
  3444 	PRINT((_L("CVDecTestEngine::SelectDecoderL, Out") ))
  3445 }
  3446 
  3447 /* ----------------------------------------------------------------------------
  3448 * Name:       CVDecTestEngine::SelectPostProcessorL()
  3449 * Purpose:
  3450 * Note:
  3451 * Parameters: None
  3452 * Return:     None
  3453 * --------------------------------------------------------------------------*/
  3454 void CVDecTestEngine::SelectPostProcessorL(const TUid& aUid)
  3455 {
  3456 	PRINT((_L("CVDecTestEngine::SelectPostProcessorL, In") ))
  3457 
  3458 	iPostProcessorUid = aUid;
  3459 	iPostProcId = iDevvp->SelectPostProcessorL(aUid);
  3460 
  3461 	PRINT((_L("CVDecTestEngine::SelectPostProcessorL, Out") ))
  3462 }
  3463 
  3464 /* ----------------------------------------------------------------------------
  3465 * Name:       CVDecTestEngine::SetBufferOptionsL()
  3466 * Purpose:
  3467 * Note:
  3468 * Parameters: None
  3469 * Return:     None
  3470 * --------------------------------------------------------------------------*/
  3471 void CVDecTestEngine::SetBufferOptionsL(const CMMFDevVideoPlay::TBufferOptions& aOptions)
  3472 {
  3473 	PRINT((_L("CVDecTestEngine::SetBufferOptionsL, In") ))
  3474 
  3475 	iInBuffSize = aOptions.iMaxInputBufferSize;
  3476 	iDevvp->SetBufferOptionsL(aOptions);
  3477 
  3478 	PRINT((_L("CVDecTestEngine::SetBufferOptionsL, Out") ))
  3479 }
  3480 
  3481 /* ----------------------------------------------------------------------------
  3482 * Name:       CVDecTestEngine::SetVideoDestScreenL()
  3483 * Purpose:
  3484 * Note:
  3485 * Parameters: None
  3486 * Return:     None
  3487 * --------------------------------------------------------------------------*/
  3488 void CVDecTestEngine::SetVideoDestScreenL(TBool aDest)
  3489 {
  3490 	PRINT((_L("CVDecTestEngine::SetVideoDestScreenL, In") ))
  3491 
  3492 	iDevvp->SetVideoDestScreenL(aDest);
  3493 
  3494 	PRINT((_L("CVDecTestEngine::SetVideoDestScreenL, Out") ))
  3495 }
  3496 
  3497 /* ----------------------------------------------------------------------------
  3498 * Name:       CVDecTestEngine::SynchronizeDecoding()
  3499 * Purpose:
  3500 * Note:
  3501 * Parameters: None
  3502 * Return:     None
  3503 * --------------------------------------------------------------------------*/
  3504 void CVDecTestEngine::SynchronizeDecoding(TBool aSynch)
  3505 {
  3506 	PRINT((_L("CVDecTestEngine::SynchronizeDecoding, In") ))
  3507 
  3508 	iDevvp->SynchronizeDecoding(aSynch);
  3509 
  3510 	PRINT((_L("CVDecTestEngine::SynchronizeDecoding, Out") ))
  3511 }
  3512 
  3513 /* ----------------------------------------------------------------------------
  3514 * Name:       CVDecTestEngine::GetBufferOptions()
  3515 * Purpose:
  3516 * Note:
  3517 * Parameters: None
  3518 * Return:     None
  3519 * --------------------------------------------------------------------------*/
  3520 void CVDecTestEngine::GetBufferOptions()
  3521 {
  3522 	PRINT((_L("CVDecTestEngine::GetBufferOptions, In") ))
  3523 
  3524 	CMMFDevVideoPlay::TBufferOptions options;
  3525 	iDevvp->GetBufferOptions(options);
  3526 
  3527 	PRINT((_L("CVDecTestEngine::GetBufferOptions: iPreDecodeBufferSize: [%d]\n iMaxPostDecodeBufferSize: [%d]\n"),
  3528 	options.iPreDecodeBufferSize, options.iMaxPostDecodeBufferSize))
  3529 	PRINT((_L("CVDecTestEngine::GetBufferOptions: iMaxInputBufferSize [%d]\n iMinNumInputBuffers [%d]\n "),
  3530 	options.iMaxInputBufferSize, options.iMinNumInputBuffers))
  3531 	PRINT((_L("CVDecTestEngine::GetBufferOptions: iPreDecoderBufferPeriod [%d] [%d]"), I64LOW(options.iPreDecoderBufferPeriod.Int64()), I64HIGH(options.iPreDecoderBufferPeriod.Int64())))
  3532 	PRINT((_L("CVDecTestEngine::GetBufferOptions: iPostDecoderBufferPeriod [%d] [%d]"), I64LOW(options.iPostDecoderBufferPeriod.Int64()), I64HIGH(options.iPostDecoderBufferPeriod.Int64())))
  3533 
  3534 	PRINT((_L("CVDecTestEngine::GetBufferOptions, Out") ))
  3535 }
  3536 
  3537 /* ----------------------------------------------------------------------------
  3538 * Name:       CVDecTestEngine::SetInputFormatL()
  3539 * Purpose:
  3540 * Note:
  3541 * Parameters: None
  3542 * Return:     None
  3543 * --------------------------------------------------------------------------*/
  3544 void CVDecTestEngine::SetInputFormatL(TInt aHwDev, const TUncompressedVideoFormat& aFormat)
  3545 {
  3546 	PRINT((_L("CVDecTestEngine::SetInputFormatL, In") ))
  3547 
  3548 	if (aHwDev == EPostProcessor)
  3549 	{
  3550 		iDevvp->SetInputFormatL(iPostProcId, aFormat);
  3551 	}
  3552 	else
  3553 	{
  3554 		iDevvp->SetInputFormatL(iDecHWDevId, aFormat);
  3555 	}
  3556 
  3557 	PRINT((_L("CVDecTestEngine::SetInputFormatL, Out") ))
  3558 }
  3559 
  3560 /* ----------------------------------------------------------------------------
  3561 * Name:       CVDecTestEngine::SetOutputFormatL()
  3562 * Purpose:
  3563 * Note:
  3564 * Parameters: None
  3565 * Return:     None
  3566 * --------------------------------------------------------------------------*/
  3567 void CVDecTestEngine::SetOutputFormatL(TInt aHwDev, const TUncompressedVideoFormat& aFormat)
  3568 {
  3569 	PRINT((_L("CVDecTestEngine::SetOutputFormatL, In") ))
  3570 
  3571 	if (aHwDev == EPostProcessor)
  3572 	{
  3573 		iDevvp->SetOutputFormatL(iPostProcId, aFormat);
  3574 	}
  3575 	else
  3576 	{
  3577 		iDevvp->SetOutputFormatL(iDecHWDevId, aFormat);
  3578 	}
  3579 
  3580 	PRINT((_L("CVDecTestEngine::SetOutputFormatL, Out") ))
  3581 }
  3582 
  3583 /* ----------------------------------------------------------------------------
  3584 * Name:       CVDecTestEngine::SetInputFormatL()
  3585 * Purpose:
  3586 * Note:
  3587 * Parameters: None
  3588 * Return:     None
  3589 * --------------------------------------------------------------------------*/
  3590 void CVDecTestEngine::SetInputFormatL(TInt aHwDev, const CCompressedVideoFormat& aFormat,
  3591 TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aEncapsulation,
  3592 TBool aDataInOrder)
  3593 {
  3594 	PRINT((_L("CVDecTestEngine::SetInputFormatL, In") ))
  3595 
  3596 	if (aHwDev == EPostProcessor)
  3597 	{
  3598 		iDevvp->SetInputFormatL(iPostProcId, aFormat, aDataUnitType, aEncapsulation, aDataInOrder);
  3599 	}
  3600 	else
  3601 	{
  3602 		iDevvp->SetInputFormatL(iDecHWDevId, aFormat, aDataUnitType, aEncapsulation, aDataInOrder);
  3603 	}
  3604 
  3605 	PRINT((_L("CVDecTestEngine::SetInputFormatL, Out") ))
  3606 }
  3607 
  3608 /* ----------------------------------------------------------------------------
  3609 * Name:       CVDecTestEngine::FindCommonFormats()
  3610 * Purpose:
  3611 * Note:
  3612 * Parameters: None
  3613 * Return:     None
  3614 * --------------------------------------------------------------------------*/
  3615 void CVDecTestEngine::FindCommonFormatsL()
  3616 {
  3617 	PRINT((_L("CVDecTestEngine::FindCommonFormatsL, In") ))
  3618 
  3619 	// Set Output Format for Decoder/Input Format for Postprocessor
  3620 	RArray<TUncompressedVideoFormat> decformats;
  3621 	TUncompressedVideoFormat commonFormat;
  3622 
  3623 
  3624 	iDevvp->GetOutputFormatListL(iDecHWDevId, decformats);
  3625 
  3626 	CPostProcessorInfo* info;
  3627 
  3628 	info = iDevvp->PostProcessorInfoLC(iPostProcessorUid);
  3629 
  3630 	RArray<TUncompressedVideoFormat> ppformats;
  3631 	ppformats = info->SupportedFormats();
  3632 
  3633 	//Find common format for dec output and postproc input
  3634 	TBool found = iDevvp->FindCommonFormat(decformats.Array(), ppformats.Array(), commonFormat);
  3635 
  3636 	if (found)
  3637 	{
  3638 		iDevvp->SetOutputFormatL(iDecHWDevId, commonFormat);
  3639 		PRINT((_L("CVDecTestEngine::FindCommonFormatsL, Decoder output Format set")))
  3640 		iDevvp->SetInputFormatL(iPostProcId, commonFormat);
  3641 		PRINT((_L("CVDecTestEngine::FindCommonFormatsL, Postprocessor input format set.")))
  3642 		PrintUncompressedFormat(commonFormat);
  3643 	}
  3644 	else
  3645 	{
  3646 		PRINT((_L("CVDecTestEngine::FindCommonFormatsL, Common Format not found")))
  3647 		User::Leave( KErrNotFound);
  3648 	}
  3649 	CleanupStack::PopAndDestroy(info);
  3650 	PRINT((_L("CVDecTestEngine::FindCommonFormatsL, closing array") ))
  3651 	decformats.Close();
  3652 	PRINT((_L("CVDecTestEngine::FindCommonFormatsL, Out") ))
  3653 }
  3654 
  3655 /* ----------------------------------------------------------------------------
  3656 * Name:       CVDecTestEngine::FindDecodersL()
  3657 * Purpose:
  3658 * Note:
  3659 * Parameters: None
  3660 * Return:     None
  3661 * --------------------------------------------------------------------------*/
  3662 TInt CVDecTestEngine::FindDecodersL(const TDesC8& aMimeType, TUint32 aPostProcType, TBool aExactMatch, TUid& aUid )
  3663 {
  3664 	PRINT((_L("CVDecTestEngine::FindDecodersL, In") ))
  3665 
  3666 	TInt supports = KErrNotSupported;
  3667 
  3668 	//UID is not set
  3669 	if (aUid.iUid == 0 && !aExactMatch)
  3670 	{
  3671 		supports = KErrNone;
  3672 	}
  3673 
  3674 	RArray<TUid> decoders;
  3675 	CleanupClosePushL(decoders);
  3676 	iDevvp->FindDecodersL(aMimeType, aPostProcType, decoders, aExactMatch);
  3677 	for (TUint i = 0; i < decoders.Count(); i++)
  3678 	{
  3679 		if (decoders[i].iUid == aUid.iUid)
  3680 		{
  3681 			supports = KErrNone;
  3682 		}
  3683 
  3684 		PRINT((_L("CVDecTestEngine::FindDecodersL, Uid [%x]"), decoders[i].iUid ))
  3685 	}
  3686 	CleanupStack::PopAndDestroy(&decoders);
  3687 
  3688 	PRINT((_L("CVDecTestEngine::FindDecodersL, Out") ))
  3689 
  3690 	return supports;
  3691 }
  3692 
  3693 /* ----------------------------------------------------------------------------
  3694 * Name:       CVDecTestEngine::FindPostProcessorsL()
  3695 * Purpose:
  3696 * Note:
  3697 * Parameters: None
  3698 * Return:     None
  3699 * --------------------------------------------------------------------------*/
  3700 TInt CVDecTestEngine::FindPostProcessorsL(TUid& aUid, TUint32 aPostProcType)
  3701 {
  3702 	PRINT((_L("CVDecTestEngine::FindPostProcessorsL, In") ))
  3703 
  3704 	TInt supports = KErrNotSupported;
  3705 
  3706 	//UID is not set
  3707 	if (aUid.iUid == 0)
  3708 	{
  3709 		supports = KErrNone;
  3710 	}
  3711 
  3712 	RArray<TUid> postProcessors;
  3713 	CleanupClosePushL(postProcessors);
  3714 	iDevvp->FindPostProcessorsL(aPostProcType, postProcessors);
  3715 	for (TUint i = 0; i < postProcessors.Count(); i++)
  3716 	{
  3717 		PRINT((_L("CVDecTestEngine::FindPostProcessorsL, Uid [%x]"), postProcessors[i].iUid ))
  3718 
  3719 		if (postProcessors[i].iUid == aUid.iUid)
  3720 		{
  3721 			supports = KErrNone;
  3722 		}
  3723 
  3724 	}
  3725 	CleanupStack::PopAndDestroy(&postProcessors);
  3726 
  3727 	PRINT((_L("CVDecTestEngine::FindPostProcessorsL, Out") ))
  3728 	return supports;
  3729 }
  3730 
  3731 /* ----------------------------------------------------------------------------
  3732 * Name:       CVDecTestEngine::GetDecoderListL()
  3733 * Purpose:
  3734 * Note:
  3735 * Parameters: None
  3736 * Return:     None
  3737 * --------------------------------------------------------------------------*/
  3738 void CVDecTestEngine::GetDecoderListL()
  3739 {
  3740 	PRINT((_L("CVDecTestEngine::GetDecoderListL, In") ))
  3741 
  3742 	RArray<TUid> decoders;
  3743 	CleanupClosePushL(decoders);
  3744 	iDevvp->GetDecoderListL(decoders);
  3745 	for (TUint i = 0; i < decoders.Count(); i++)
  3746 	{
  3747 		PRINT((_L("CVDecTestEngine::GetDecoderListL, Uid [%x]"), decoders[i].iUid ))
  3748 	}
  3749 	CleanupStack::PopAndDestroy(&decoders);
  3750 
  3751 	PRINT((_L("CVDecTestEngine::GetDecoderListL, Out") ))
  3752 }
  3753 
  3754 /* ----------------------------------------------------------------------------
  3755 * Name:       CVDecTestEngine::ConfigureDecoderL()
  3756 * Purpose:
  3757 * Note:
  3758 * Parameters: None
  3759 * Return:     None
  3760 * --------------------------------------------------------------------------*/
  3761 void CVDecTestEngine::ConfigureDecoderL(TVideoPictureHeader& aVideoPictureHeader)
  3762 {
  3763 	PRINT((_L("CVDecTestEngine::ConfigureDecoderL, In") ))
  3764 
  3765 	if( iSetPassword )
  3766 	{
  3767 		TBuf16<128> tempBuf;
  3768 		tempBuf.Copy( iPasswordForFLV);
  3769 		PRINT( ( _L( "CVDecTestEngine::ConfigureDecoderL(): password tempBuf: %S." ), &tempBuf ) )
  3770 
  3771 		TPtrC8 metaData((TUint8*)iPasswordForFLV.Ptr(), iPasswordForFLV.Size());
  3772 
  3773 		aVideoPictureHeader.iOptional = &metaData;
  3774 
  3775 	}
  3776 
  3777 	iDevvp->ConfigureDecoderL(aVideoPictureHeader);
  3778 
  3779 	PRINT((_L("CVDecTestEngine::ConfigureDecoderL, Out") ))
  3780 }
  3781 
  3782 
  3783 /* ----------------------------------------------------------------------------
  3784 * Name:       CVDecTestEngine::ConfigureDecoderL()
  3785 * Purpose:
  3786 * Note:
  3787 * Parameters: None
  3788 * Return:     None
  3789 * --------------------------------------------------------------------------*/
  3790 void CVDecTestEngine::ConfigureDecoderL()
  3791 {
  3792 	PRINT((_L("CVDecTestEngine::ConfigureDecoderL, In") ))
  3793 
  3794 	if (iCodecType == EVC1)
  3795 	{
  3796 		PRINT((_L("CVDecTestEngine::ConfigureDecoderL, iCodectype VC1") ))
  3797 		TInt configPosition = 0;
  3798 		TUint configDataSize = 36; // MetaData is 36 Bytes in SP-L0 VC1 .
  3799 		TUint8* ptr = new (ELeave) TUint8[configDataSize+8];
  3800 		iMemAlloc++;
  3801 		#ifdef __MEM_CHECK_
  3802 		PRINT((_L("CVDecTestEngine::ConfigureDecoderL, mem alloc, ptr") ))
  3803 		#endif
  3804 		TUint32* ptr32 = reinterpret_cast<TUint32*>(ptr);
  3805 		ptr32[0] = 1;
  3806 		ptr32[1] = 44;
  3807 		TPtr8 configData((ptr+8), configDataSize);
  3808 		for (TUint i=0; i < 8; i++)
  3809 		{
  3810 			PRINT((_L("CVDecTestEngine::ConfigureDecoderL, beginning [%d]"), ptr[i] ))
  3811 		}
  3812 
  3813 		User::LeaveIfError(iInFile.Seek(ESeekStart, configPosition));
  3814 		User::LeaveIfError(iInFile.Read(configData, configDataSize));
  3815 		TVideoPictureHeader* configHeader = new TVideoPictureHeader;
  3816 		iMemAlloc++;
  3817 		CleanupStack::PushL(configHeader);
  3818 		#ifdef __MEM_CHECK_
  3819 		PRINT((_L("CVDecTestEngine::ConfigureDecoderL, mem alloc, configHeader") ))
  3820 		#endif
  3821 
  3822 		TPtrC8 metaData(ptr,configDataSize+8);
  3823 
  3824 
  3825 		configHeader->iOptional = &metaData;
  3826 		configHeader->iLevel = -1;
  3827 		configHeader->iProfile = -1;
  3828 
  3829 		iDevvp->ConfigureDecoderL(*configHeader);
  3830 
  3831 
  3832 		CleanupStack::Pop();
  3833 		delete ptr;
  3834 		iMemDelete++;
  3835 		delete configHeader;
  3836 		iMemDelete++;
  3837 		#ifdef __MEM_CHECK_
  3838 		PRINT((_L("CVDecTestEngine::ConfigureDecoderL, mem del, ptr & configHeader") ))
  3839 		#endif
  3840 		return;
  3841 	}
  3842 
  3843 	TInt err = KErrNone;
  3844 	TVideoPictureHeader* headerInfo = NULL;
  3845 	HBufC8* tempBuff = NULL;
  3846 
  3847 	//Read Picture header : Size is not known
  3848 	TVideoInputBuffer* codedBuffer = new(ELeave) TVideoInputBuffer;
  3849 	CleanupStack::PushL( codedBuffer );
  3850 	iInBuffSize = KMaxCodedSize;
  3851 	err = KErrOverflow;
  3852 
  3853 	while ( (err == KErrOverflow) && (iInBuffSize <= KMaxCodedSize) )
  3854 	{
  3855 		tempBuff = HBufC8::NewL(iInBuffSize);
  3856 		CleanupStack::PushL( tempBuff );
  3857 		codedBuffer->iData.Set(tempBuff->Des());
  3858 
  3859 		if ( iFrameSizeList.Count() > 0 )
  3860 		{
  3861 			err = ReadOneCodedPicture(codedBuffer, iFrameSizeList[0] );
  3862 		}
  3863 		else
  3864 		{
  3865 			err = ReadOneCodedPicture(codedBuffer);
  3866 		}
  3867 		//err = ReadOneCodedPicture(codedBuffer);
  3868 
  3869 		TInt pos =0;
  3870 		if ( iInFile.Seek(ESeekStart,pos) )
  3871 		{
  3872 			err = KErrGeneral;
  3873 		}
  3874 
  3875 		if ( iInputEnd )
  3876 		{
  3877 			err = KErrNotFound;
  3878 		}
  3879 
  3880 		if ( err < 0 )
  3881 		{
  3882 			CleanupStack::PopAndDestroy(tempBuff);
  3883 			iInBuffSize = 4*iInBuffSize;
  3884 		}
  3885 	}
  3886 
  3887 
  3888 	// Reitrieve header information from bitstream
  3889 	if ( err  < 0 )
  3890 	{
  3891 		CleanupStack::PopAndDestroy(codedBuffer);
  3892 		PRINT((_L("CVDecTestEngine::ConfigureDecoderL, Reading input data fail")))
  3893 	}
  3894 	else
  3895 	{
  3896 		err = KErrNone;
  3897 
  3898 		headerInfo = iDevvp->GetHeaderInformationL(EDuCodedPicture,EDuElementaryStream,codedBuffer);
  3899 
  3900 		CleanupStack::PopAndDestroy(tempBuff);
  3901 		CleanupStack::PopAndDestroy(codedBuffer);
  3902 
  3903 		//Check Header info
  3904 		if ( headerInfo )
  3905 		{
  3906 
  3907 			PRINT((_L("CVDecTestEngine::ConfigureDecoderL, Configuring the decoder")))
  3908 
  3909 
  3910 			if( iSetPassword )
  3911 			{
  3912 				TBuf16<128> tempBuf;
  3913 				tempBuf.Copy( iPasswordForFLV);
  3914 				PRINT( ( _L( "CVDecTestEngine::ConfigureDecoderL(): password tempBuf: %S." ), &tempBuf ) )
  3915 
  3916 				TPtrC8 metaData((TUint8*)iPasswordForFLV.Ptr(), iPasswordForFLV.Size());
  3917 
  3918 				headerInfo->iOptional = &metaData;
  3919 
  3920 			}
  3921 			iDevvp->ConfigureDecoderL(*headerInfo);
  3922 
  3923 			//return headerInfo
  3924 			iDevvp->ReturnHeader(headerInfo);
  3925 
  3926 		}
  3927 		else
  3928 		{
  3929 			PRINT((_L("CVDecTestEngine::ConfigureDecoderL, Get header info fail")))
  3930 			err = KErrGeneral;
  3931 		}
  3932 
  3933 	}
  3934 
  3935 	// Set size of decoder input buffer
  3936 	if ( iCodecType == EH263 )
  3937 	{
  3938 		if ( (iPictureSize.iWidth <= 176 ) && (iPictureSize.iHeight <= 144) )
  3939 		iInBuffSize = KH263MaxCodedSizeQCIF;
  3940 		else
  3941 		iInBuffSize = KH263MaxCodedSizeCIF;
  3942 
  3943 	}
  3944 	else //Mpeg4 and AVC and FLV
  3945 	{
  3946 		if ( (iPictureSize.iWidth <= 176 ) && (iPictureSize.iHeight <= 144) )
  3947 		iInBuffSize = KMP4MaxCodedSizeQCIF;
  3948 		else if ( (iPictureSize.iWidth <= 352 ) && (iPictureSize.iHeight <= 288) )
  3949 		iInBuffSize = KMP4MaxCodedSizeCIF;
  3950 		else if ( (iPictureSize.iWidth <= 640 ) && (iPictureSize.iHeight <= 480) )
  3951 		iInBuffSize = KMP4MaxCodedSizeVGA;
  3952 		else if  ( (iPictureSize.iWidth <= 720 ) && (iPictureSize.iHeight <= 576) )
  3953 		iInBuffSize = KMP4MaxCodedSizePAL;
  3954 		else
  3955 		iInBuffSize = KMaxCodedSize;
  3956 	}
  3957 
  3958 	AssertTIntEqualL(KErrNone, err);
  3959 
  3960 	TInt pos =0;
  3961 	iSentBuffCount = 0;
  3962 	iReadDataChunk = iDataChunk;
  3963 	iWriteDataChunk = iDataChunk;
  3964 	iDataReadFromFile = 0;
  3965 	iInFile.Seek(ESeekStart,pos);
  3966 
  3967 	PRINT((_L("CVDecTestEngine::ConfigureDecoderL, Out") ))
  3968 }
  3969 
  3970 /* ----------------------------------------------------------------------------
  3971 * Name:       CVDecTestEngine::GetOutputFormatListL()
  3972 * Purpose:
  3973 * Note:
  3974 * Parameters: None
  3975 * Return:     None
  3976 * --------------------------------------------------------------------------*/
  3977 void CVDecTestEngine::GetOutputFormatListL(TInt aHWDevice)
  3978 {
  3979 	PRINT((_L("CVDecTestEngine::GetOutputFormatListL, In") ))
  3980 
  3981 	RArray<TUncompressedVideoFormat> formats;
  3982 	CleanupClosePushL(formats);
  3983 	if (aHWDevice == EPostProcessor)
  3984 	{
  3985 		iDevvp->GetOutputFormatListL(iPostProcId, formats);
  3986 	}
  3987 	else
  3988 	{
  3989 		iDevvp->GetOutputFormatListL(iDecHWDevId, formats);
  3990 	}
  3991 
  3992 	for (TUint i = 0; i < formats.Count(); i++)
  3993 	{
  3994 		PRINT((_L("CVDecTestEngine::GetOutputFormatListL, Format No.%d"), i))
  3995 		PrintUncompressedFormat(formats[i]);
  3996 	}
  3997 	CleanupStack::PopAndDestroy(&formats);
  3998 
  3999 	PRINT((_L("CVDecTestEngine::GetOutputFormatListL, Out") ))
  4000 }
  4001 
  4002 /* ----------------------------------------------------------------------------
  4003 * Name:       CVDecTestEngine::SupportsOutputFormatL()
  4004 * Purpose:
  4005 * Note:
  4006 * Parameters: None
  4007 * Return:     None
  4008 * --------------------------------------------------------------------------*/
  4009 TInt CVDecTestEngine::SupportsOutputFormatL(TInt aHwdev, const TUncompressedVideoFormat& aFormat)
  4010 {
  4011 	PRINT((_L("CVDecTestEngine::SupportsOutputFormatL, In") ))
  4012 
  4013 	TInt result = KErrNotSupported;
  4014 
  4015 	RArray<TUncompressedVideoFormat> formats;
  4016 	CleanupClosePushL(formats);
  4017 	if (aHwdev == EPostProcessor)
  4018 	{
  4019 		iDevvp->GetOutputFormatListL(iPostProcId, formats);
  4020 	}
  4021 	else
  4022 	{
  4023 		iDevvp->GetOutputFormatListL(iDecHWDevId, formats);
  4024 	}
  4025 
  4026 	for (TUint i = 0; i < formats.Count(); i++)
  4027 	{
  4028 		PRINT((_L("CVDecTestEngine::SupportsOutputFormatL, Format No.%d"), i))
  4029 		if (formats[i] == aFormat)
  4030 		{
  4031 			result = KErrNone;
  4032 		}
  4033 		PrintUncompressedFormat(formats[i]);
  4034 	}
  4035 	CleanupStack::PopAndDestroy(&formats);
  4036 
  4037 	PRINT((_L("CVDecTestEngine::SupportsOutputFormatL, Out") ))
  4038 
  4039 	return result;
  4040 }
  4041 
  4042 /* ----------------------------------------------------------------------------
  4043 * Name:       CVDecTestEngine::GetPostProcessorListL()
  4044 * Purpose:
  4045 * Note:
  4046 * Parameters: None
  4047 * Return:     None
  4048 * --------------------------------------------------------------------------*/
  4049 void CVDecTestEngine::GetPostProcessorListL()
  4050 {
  4051 	PRINT((_L("CVDecTestEngine::GetPostProcessorListL, Out") ))
  4052 
  4053 	RArray<TUid> postProcessors;
  4054 	CleanupClosePushL(postProcessors);
  4055 	iDevvp->GetPostProcessorListL(postProcessors);
  4056 	for (TUint i = 0; i < postProcessors.Count(); i++)
  4057 	{
  4058 		PRINT((_L("CVDecTestEngine::GetPostProcessorListL, Uid [%x]"), postProcessors[i].iUid ))
  4059 	}
  4060 	CleanupStack::PopAndDestroy(&postProcessors);
  4061 
  4062 	PRINT((_L("CVDecTestEngine::GetPostProcessorListL, Out") ))
  4063 }
  4064 
  4065 /* ----------------------------------------------------------------------------
  4066 * Name:       CVDecTestEngine::VideoDecoderInfoL()
  4067 * Purpose:
  4068 * Note:
  4069 * Parameters: None
  4070 * Return:     None
  4071 * --------------------------------------------------------------------------*/
  4072 void CVDecTestEngine::VideoDecoderInfoL(TUid aVideoDecoder)
  4073 {
  4074 	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, In") ))
  4075 
  4076 	CVideoDecoderInfo* info;
  4077 	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, 2test") ))
  4078 	info = iDevvp->VideoDecoderInfoLC(aVideoDecoder);
  4079 
  4080 	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, test") ))
  4081 
  4082 	TVersion version = info->Version();
  4083 	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, Manufacturer: %S"), &info->Manufacturer()))
  4084 	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, Identifier: %S"), &info->Identifier()))
  4085 	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, Version information:")))
  4086 	PRINT((_L("Major Version:[%d], Minor Version:[%d], Build number:[%d] "), version.iMajor,version.iMinor,version.iBuild))
  4087 	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, HW Accelerated:[%d]"),info->Accelerated()))
  4088 	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, Support Direct Screen:[%d]"),info->SupportsDirectDisplay()))
  4089 	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, MaxPictureSize, %dx%d"),info->MaxPictureSize().iWidth, info->MaxPictureSize().iHeight))
  4090 	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, MaxBitrate: [%d]"),info->MaxBitrate()))
  4091 	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, SupportsPictureLoss: [%d]"),info->SupportsPictureLoss()))
  4092 	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, SupportsSliceLoss: [%d]"),info->SupportsSliceLoss()))
  4093 	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, CodingStandardSpecificInfo: %S"), &info->CodingStandardSpecificInfo()))
  4094 	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, ImplementationSpecificInfo: %S"), &info->ImplementationSpecificInfo()))
  4095 
  4096 	CleanupStack::PopAndDestroy(info);
  4097 
  4098 	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, Out") ))
  4099 }
  4100 
  4101 /* ----------------------------------------------------------------------------
  4102 * Name:       CVDecTestEngine::PostProcessorInfoL()
  4103 * Purpose:
  4104 * Note:
  4105 * Parameters: None
  4106 * Return:     None
  4107 * --------------------------------------------------------------------------*/
  4108 void CVDecTestEngine::PostProcessorInfoL(TUid aPostProcessor)
  4109 {
  4110 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, In") ))
  4111 
  4112 	CPostProcessorInfo* info;
  4113 	info = iDevvp->PostProcessorInfoLC(aPostProcessor);
  4114 
  4115 	TVersion version = info->Version();
  4116 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Manufacturer: %S"), &info->Manufacturer()))
  4117 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Identifier: %S"), &info->Identifier()))
  4118 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Version information:")))
  4119 	PRINT((_L("Major Version:[%d], Minor Version:[%d], Build number:[%d] "), version.iMajor,version.iMinor,version.iBuild))
  4120 
  4121 	// combination
  4122 	RArray<TUint32> combination = info->SupportedCombinations();
  4123 
  4124 	for (TInt i=0; i < combination.Count(); i++)
  4125 	{
  4126 		PRINT((_L("CVDecTestEngine::PostProcessorInfoL, combiantion:[%x]"), combination.operator[](i)))
  4127 	}
  4128 
  4129 	//Color Conversion YUV to RGV
  4130 	TYuvToRgbCapabilities colorconv;
  4131 	colorconv = info->YuvToRgbCapabilities();
  4132 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, YUV Sampling Pattern bit:[0x%x]"),colorconv.iSamplingPatterns))
  4133 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, YUV Coefficient bit:[0x%x]"),colorconv.iCoefficients))
  4134 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, RGB Formats bit:[0x%x]"),colorconv.iRgbFormats))
  4135 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Lightness Control:[%d]"),colorconv.iLightnessControl))
  4136 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Saturation Control:[%d]"),colorconv.iSaturationControl))
  4137 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Contrast Control:[%d]"),colorconv.iContrastControl))
  4138 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Gamma Correction:[%d]"),colorconv.iGammaCorrection))
  4139 
  4140 	if(colorconv.iDitherTypes  & EDitherNone)
  4141 	{
  4142 		PRINT((_L("CVDecTestEngine::PostProcessorInfoL, No dither support")))
  4143 	}
  4144 	if(colorconv.iDitherTypes  & EDitherOrdered)
  4145 	{
  4146 		PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Ordered Dither")))
  4147 	}
  4148 	if(colorconv.iDitherTypes  & EDitherErrorDiffusion)
  4149 	{
  4150 		PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Error diffusion dither")))
  4151 	}
  4152 	if(colorconv.iDitherTypes  & EDitherOther)
  4153 	{
  4154 		PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Other hardware device specific dithering type")))
  4155 	}
  4156 
  4157 
  4158 	//HW Accelated
  4159 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, HW Accelerated:[%d]"),info->Accelerated()))
  4160 
  4161 	//Support Direct Screen
  4162 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Direct Screen:[%d]"),info->SupportsDirectDisplay()))
  4163 
  4164 	//Rotation
  4165 	TUint rotation;
  4166 	rotation =  info->SupportedRotations();
  4167 
  4168 	if(rotation & 0x00000001)
  4169 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Rotation: 90Clockwise ")))
  4170 	if(rotation & 0x00000002)
  4171 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Rotation: 90Anticlockwise ")))
  4172 	if(rotation & 0x00000004)
  4173 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Rotation: 180 ")))
  4174 	if(!(rotation & 0x00000007))
  4175 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, No Rotation supported ")))
  4176 
  4177 	//Arbitrary Scaling
  4178 	TInt support = info->SupportsArbitraryScaling();
  4179 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Arbitrary Scaling:[%d]"),support))
  4180 
  4181 	//Scalling Factor
  4182 	if ( support )
  4183 	{
  4184 		RArray<TScaleFactor> scale = info->SupportedScaleFactors();
  4185 
  4186 		for (TInt i=0; i<scale.Count(); i++)
  4187 		{
  4188 			PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Scalling Factor:[%d]/[%d]"),scale.operator[](i).iScaleNum, scale.operator[](i).iScaleDenom))
  4189 		}
  4190 	}
  4191 
  4192 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Anti Aliased filter:[%d]"),info->AntiAliasedScaling()))
  4193 
  4194 	CleanupStack::PopAndDestroy(info);
  4195 
  4196 	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Out") ))
  4197 }
  4198 
  4199 /* ----------------------------------------------------------------------------
  4200 * Name:       CVDecTestEngine::SupportsFormatL()
  4201 * Purpose:    Retrieves information about an installed video decoder
  4202 * Parameters: None
  4203 * Return:     None
  4204 * --------------------------------------------------------------------------*/
  4205 
  4206 TInt CVDecTestEngine::SupportsFormatL(const TUid& aUid, const CCompressedVideoFormat& aFormat)
  4207 {
  4208 	PRINT((_L("CVDecTestEngine::SupportsFormatL(),In")))
  4209 
  4210 	TInt supports = KErrNotSupported;
  4211 
  4212 	CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  4213 	if(!info)
  4214 	{
  4215 		PRINT((_L("CVDecTestEngine::SupportsFormatL(),Error")))
  4216 		return KErrGeneral;
  4217 	}
  4218 
  4219 	if (info->SupportsFormat(aFormat))
  4220 	{
  4221 		PRINT((_L("CVDecTestEngine::SupportsFormatL, Supported format found")))
  4222 		supports=KErrNone;
  4223 	}
  4224 
  4225 	CleanupStack::PopAndDestroy();
  4226 
  4227 	PRINT((_L("CVDecTestEngine::SupportsFormatL(),Out")))
  4228 	return supports;
  4229 }
  4230 
  4231 
  4232 /* ----------------------------------------------------------------------------
  4233 * Name:       CVDecTestEngine::SupportsFormatInfoL()
  4234 * Purpose:    Retrieves information about an installed video decoder
  4235 * Parameters: None
  4236 * Return:     None
  4237 * --------------------------------------------------------------------------*/
  4238 
  4239 TInt CVDecTestEngine::SupportsFormatInfoL(const TUid& aUid, const CCompressedVideoFormat& aFormat)
  4240 {
  4241 	PRINT((_L("CVDecTestEngine::SupportsFormatInfoL(),In")))
  4242 
  4243 	TInt supports = KErrNotSupported;
  4244 	RPointerArray<CCompressedVideoFormat> formats;
  4245 
  4246 	CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  4247 	if(!info)
  4248 	{
  4249 		PRINT((_L("CVDecTestEngine::SupportsFormatInfoL(),Error")))
  4250 		formats.Close();
  4251 		return KErrGeneral;
  4252 	}
  4253 
  4254 	formats = info->SupportedFormats();
  4255 
  4256 	PRINT((_L("CVDecTestEngine::SupportsFormatInfoL(), supported formats")))
  4257 
  4258 	for (TUint i = 0; i < formats.Count(); i++)
  4259 	{
  4260 		TBuf16<128> format;
  4261 		format.Copy(formats[i]->MimeType());
  4262 		PRINT((_L("CVDecTestEngine::SupportsFormatInfoL, Format [%S]"), &format))
  4263 		//PRINT((_L("CVDecTestEngine::SupportsFormatInfoL, %d. Format [%S]"), &(formats[i]))
  4264 		if (*(formats[i]) == aFormat)
  4265 		{
  4266 			supports = KErrNone;
  4267 			PRINT((_L("CVDecTestEngine::SupportsFormatInfoL, Supported format found")))
  4268 		}
  4269 	}
  4270 
  4271 	CleanupStack::PopAndDestroy();
  4272 
  4273 	PRINT((_L("CVDecTestEngine::SupportsFormatInfoL(),Out")))
  4274 	return supports;
  4275 }
  4276 
  4277 /* ----------------------------------------------------------------------------
  4278 * Name:       CVDecTestEngine::SupportsAccelerationL()
  4279 * Purpose:    Retrieves information about an installed video decoder
  4280 * Parameters: None
  4281 * Return:     None
  4282 * --------------------------------------------------------------------------*/
  4283 
  4284 TInt CVDecTestEngine::SupportsAccelerationL(TInt aHwDev, const TUid& aUid)
  4285 {
  4286 	PRINT((_L("CVDecTestEngine::SupportsAccelerationL(),In")))
  4287 
  4288 	TInt supports = KErrNotSupported;
  4289 	TBool supported = EFalse;
  4290 
  4291 	if (aHwDev == EPostProcessor)
  4292 	{
  4293 		CPostProcessorInfo* info = iDevvp->PostProcessorInfoLC(aUid);
  4294 		if(!info)
  4295 		{
  4296 			PRINT((_L("CVDecTestEngine::SupportsAccelerationL(),Error")))
  4297 			return KErrGeneral;
  4298 		}
  4299 		supported = info->Accelerated();
  4300 	}
  4301 	else
  4302 	{
  4303 		CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  4304 		if(!info)
  4305 		{
  4306 			PRINT((_L("CVDecTestEngine::SupportsAccelerationL(),Error")))
  4307 			return KErrGeneral;
  4308 		}
  4309 
  4310 		supported = info->Accelerated();
  4311 	}
  4312 
  4313 	if (supported)
  4314 	{
  4315 		supports = KErrNone;
  4316 	}
  4317 
  4318 	CleanupStack::PopAndDestroy();
  4319 
  4320 	PRINT((_L("CVDecTestEngine::SupportsAccelerationL(),Out")))
  4321 	return supports;
  4322 }
  4323 
  4324 /* ----------------------------------------------------------------------------
  4325 * Name:       CVDecTestEngine::SupportsDirectDisplayL()
  4326 * Purpose:    Retrieves information about an installed video decoder
  4327 * Parameters: None
  4328 * Return:     None
  4329 * --------------------------------------------------------------------------*/
  4330 
  4331 TInt CVDecTestEngine::SupportsDirectDisplayL(TInt aHwDev, const TUid& aUid)
  4332 {
  4333 	PRINT((_L("CVDecTestEngine::SupportsDirectDisplayL(),In")))
  4334 
  4335 	TInt supports = KErrNotSupported;
  4336 	TBool supported = EFalse;
  4337 
  4338 	if (aHwDev == EPostProcessor)
  4339 	{
  4340 		CPostProcessorInfo* info = iDevvp->PostProcessorInfoLC(aUid);
  4341 		if(!info)
  4342 		{
  4343 			PRINT((_L("CVDecTestEngine::SupportsDirectDisplayL(),Error")))
  4344 			return KErrGeneral;
  4345 		}
  4346 
  4347 		supported = info->SupportsDirectDisplay();
  4348 	}
  4349 	else
  4350 	{
  4351 		CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  4352 		if(!info)
  4353 		{
  4354 			PRINT((_L("CVDecTestEngine::SupportsDirectDisplayL(),Error")))
  4355 			return KErrGeneral;
  4356 		}
  4357 
  4358 		supported = info->SupportsDirectDisplay();
  4359 	}
  4360 
  4361 	if (supported)
  4362 	{
  4363 		supports = KErrNone;
  4364 	}
  4365 
  4366 	CleanupStack::PopAndDestroy();
  4367 
  4368 	PRINT((_L("CVDecTestEngine::SupportsDirectDisplayL(),Out")))
  4369 	return supports;
  4370 }
  4371 
  4372 
  4373 /* ----------------------------------------------------------------------------
  4374 * Name:       CVDecTestEngine::SupportsMaxPictureSizeL()
  4375 * Purpose:    Retrieves information about an installed video decoder
  4376 * Parameters: None
  4377 * Return:     None
  4378 * --------------------------------------------------------------------------*/
  4379 
  4380 TInt CVDecTestEngine::SupportsMaxPictureSizeL(const TUid& aUid, TSize aSize)
  4381 {
  4382 	PRINT((_L("CVDecTestEngine::SupportsMaxPictureSizeL(),In")))
  4383 
  4384 	TInt supports = KErrNotSupported;
  4385 
  4386 	CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  4387 	if(!info)
  4388 	{
  4389 		PRINT((_L("CVDecTestEngine::SupportsMaxPictureSizeL(),Error")))
  4390 		return KErrGeneral;
  4391 	}
  4392 
  4393 	TSize size = info->MaxPictureSize();
  4394 
  4395 	if (size.iWidth >= aSize.iWidth && size.iHeight >= aSize.iHeight)
  4396 	{
  4397 		supports = KErrNone;
  4398 	}
  4399 
  4400 	CleanupStack::PopAndDestroy();
  4401 
  4402 	PRINT((_L("CVDecTestEngine::SupportsMaxPictureSizeL(),Out")))
  4403 	return supports;
  4404 }
  4405 
  4406 /* ----------------------------------------------------------------------------
  4407 * Name:       CVDecTestEngine::SupportsMaxPictureRateL()
  4408 * Purpose:    Retrieves information about an installed video decoder
  4409 * Parameters: None
  4410 * Return:     None
  4411 * --------------------------------------------------------------------------*/
  4412 
  4413 TInt CVDecTestEngine::SupportsMaxPictureRateL(const TUid& aUid, TPictureRateAndSize& aRateAndSize)
  4414 {
  4415 	PRINT((_L("CVDecTestEngine::SupportsMaxPictureRateL(),In")))
  4416 
  4417 	TInt supports = KErrNotSupported;
  4418 	TPictureRateAndSize picRateAndSize;
  4419 
  4420 	CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  4421 	if(!info)
  4422 	{
  4423 		PRINT((_L("CVEncTestEngine::SupportsMaxPictureRateL(),Error")))
  4424 		return KErrGeneral;
  4425 	}
  4426 
  4427 	RArray<TPictureRateAndSize> picRateAndSizeArray = info->MaxPictureRates();
  4428 
  4429 	for (TUint i=0; i < picRateAndSizeArray.Count(); i++)
  4430 	{
  4431 		picRateAndSize = picRateAndSizeArray[i];
  4432 		if (aRateAndSize.iPictureRate <= picRateAndSize.iPictureRate && aRateAndSize.iPictureSize.iWidth <= picRateAndSize.iPictureSize.iWidth &&
  4433 		aRateAndSize.iPictureSize.iHeight <= picRateAndSize.iPictureSize.iHeight)
  4434 		{
  4435 			supports = KErrNone;
  4436 		}
  4437 	}
  4438 
  4439 	CleanupStack::PopAndDestroy();
  4440 
  4441 	PRINT((_L("CVDecTestEngine::SupportsMaxPictureRateL(),Out")))
  4442 	return supports;
  4443 }
  4444 
  4445 
  4446 /* ----------------------------------------------------------------------------
  4447 * Name:       CVDecTestEngine::SupportsSliceLossL()
  4448 * Purpose:    Retrieves information about an installed video decoder
  4449 * Parameters: None
  4450 * Return:     None
  4451 * --------------------------------------------------------------------------*/
  4452 
  4453 TInt CVDecTestEngine::SupportsSliceLossL(const TUid& aUid)
  4454 {
  4455 	PRINT((_L("CVDecTestEngine::SupportsSliceLossL(),In")))
  4456 
  4457 	TInt supports = KErrNotSupported;
  4458 	TBool supported = EFalse;
  4459 
  4460 	CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  4461 	if(!info)
  4462 	{
  4463 		PRINT((_L("CVDecTestEngine::SupportsSliceLossL(),Error")))
  4464 		return KErrGeneral;
  4465 	}
  4466 
  4467 	supported = info->SupportsSliceLoss();
  4468 
  4469 	if (supported)
  4470 	{
  4471 		supports = KErrNone;
  4472 	}
  4473 
  4474 	CleanupStack::PopAndDestroy();
  4475 
  4476 	PRINT((_L("CVDecTestEngine::SupportsSliceLossL(),Out")))
  4477 	return supports;
  4478 }
  4479 
  4480 /* ----------------------------------------------------------------------------
  4481 * Name:       CVDecTestEngine::SupportsPictureLossL()
  4482 * Purpose:    Retrieves information about an installed video decoder
  4483 * Parameters: None
  4484 * Return:     None
  4485 * --------------------------------------------------------------------------*/
  4486 
  4487 TInt CVDecTestEngine::SupportsPictureLossL(const TUid& aUid)
  4488 {
  4489 	PRINT((_L("CVDecTestEngine::SupportsPictureLossL(),In")))
  4490 
  4491 	TInt supports = KErrNotSupported;
  4492 	TBool supported = EFalse;
  4493 
  4494 	CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  4495 	if(!info)
  4496 	{
  4497 		PRINT((_L("CVDecTestEngine::SupportsPictureLossL(),Error")))
  4498 		return KErrGeneral;
  4499 	}
  4500 
  4501 	supported = info->SupportsPictureLoss();
  4502 
  4503 	if (supported)
  4504 	{
  4505 		supports = KErrNone;
  4506 	}
  4507 
  4508 	CleanupStack::PopAndDestroy();
  4509 
  4510 	PRINT((_L("CVDecTestEngine::SupportsPictureLossL(),Out")))
  4511 	return supports;
  4512 }
  4513 
  4514 
  4515 /* ----------------------------------------------------------------------------
  4516 * Name:       CVDecTestEngine::SupportsMaxBitrateL()
  4517 * Purpose:    Retrieves information about an installed video encoder
  4518 * Parameters: None
  4519 * Return:     None
  4520 * --------------------------------------------------------------------------*/
  4521 
  4522 TInt CVDecTestEngine::SupportsMaxBitrateL(const TUid& aUid, TInt aBitrate)
  4523 {
  4524 	PRINT((_L("CVDecTestEngine::SupportsMaxBitrateL(),In")))
  4525 
  4526 	TInt supports = KErrNotSupported;
  4527 	TInt bitrate = 0;
  4528 
  4529 	CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  4530 	if(!info)
  4531 	{
  4532 		PRINT((_L("CVDecTestEngine::SupportsMaxBitrateL(),Error")))
  4533 		return KErrGeneral;
  4534 	}
  4535 
  4536 	bitrate = info->MaxBitrate();
  4537 
  4538 	if (aBitrate <= bitrate)
  4539 	{
  4540 		supports = KErrNone;
  4541 	}
  4542 
  4543 	CleanupStack::PopAndDestroy();
  4544 
  4545 	PRINT((_L("CVDecTestEngine::SupportsMaxBitrateL(),Out")))
  4546 	return supports;
  4547 }
  4548 
  4549 
  4550 /* ----------------------------------------------------------------------------
  4551 * Name:       CVDecTestEngine::SetYuvToRgbOptionsL()
  4552 * Purpose:
  4553 * Note:
  4554 * Parameters: None
  4555 * Return:     None
  4556 * --------------------------------------------------------------------------*/
  4557 void CVDecTestEngine::SetYuvToRgbOptionsL(TInt aHWDevice, const TYuvToRgbOptions& aOptions, const TYuvFormat& aYuvFormat, TRgbFormat aRgbFormat)
  4558 {
  4559 	PRINT((_L("CVDecTestEngine::SetYuvToRgbOptionsL, In") ))
  4560 
  4561 	if (aHWDevice == EPostProcessor)
  4562 	{
  4563 		iDevvp->SetYuvToRgbOptionsL(iPostProcId, aOptions, aYuvFormat, aRgbFormat);
  4564 	}
  4565 	else
  4566 	{
  4567 		iDevvp->SetYuvToRgbOptionsL(iDecHWDevId, aOptions, aYuvFormat, aRgbFormat);
  4568 	}
  4569 
  4570 	PRINT((_L("CVDecTestEngine::SetYuvToRgbOptionsL, Out") ))
  4571 }
  4572 
  4573 /* ----------------------------------------------------------------------------
  4574 * Name:       CVDecTestEngine::SetSlowClient()
  4575 * Purpose:
  4576 * Note:
  4577 * Parameters: None
  4578 * Return:     None
  4579 * --------------------------------------------------------------------------*/
  4580 void CVDecTestEngine::SetSlowClient(TBool aOption)
  4581 {
  4582 	PRINT((_L("CVDecTestEngine::SetSlowClient, In") ))
  4583 
  4584 	iSetSlowClient = aOption;
  4585 
  4586 	PRINT((_L("CVDecTestEngine::SetSlowClient, Out") ))
  4587 }
  4588 
  4589 /* ----------------------------------------------------------------------------
  4590 * Name:       CVDecTestEngine::SetFastClient()
  4591 * Purpose:
  4592 * Note:
  4593 * Parameters: None
  4594 * Return:     None
  4595 * --------------------------------------------------------------------------*/
  4596 void CVDecTestEngine::SetFastClient(TBool aOption)
  4597 {
  4598 	PRINT((_L("CVDecTestEngine::SetFastClient, In") ))
  4599 
  4600 	iSetFastClient = aOption;
  4601 
  4602 	PRINT((_L("CVDecTestEngine::SetFastClient, Out") ))
  4603 }
  4604 
  4605 /* ----------------------------------------------------------------------------
  4606 * Name:       CVDecTestEngine::SetAUFormat()
  4607 * Purpose:
  4608 * Note:
  4609 * Parameters: None
  4610 * Return:     None
  4611 * --------------------------------------------------------------------------*/
  4612 TInt CVDecTestEngine::SetAUFormat()
  4613 {
  4614 	PRINT((_L("CVDecTestEngine::SetAUFormat, In") ))
  4615 
  4616 	if (iCodecType== EAVC)
  4617 	{
  4618 		iSetAUFormat = ETrue;
  4619 
  4620 	}
  4621 	else
  4622 	{
  4623 		return KErrNotSupported;
  4624 	}
  4625 
  4626 	PRINT((_L("CVDecTestEngine::SetAUFormat, Out") ))
  4627 
  4628 	return KErrNone;
  4629 }
  4630 
  4631 /* ----------------------------------------------------------------------------
  4632 * Name:       CVDecTestEngine::MoveFileL()
  4633 * Purpose:
  4634 * Note:
  4635 * Parameters: None
  4636 * Return:     None
  4637 * --------------------------------------------------------------------------*/
  4638 TInt CVDecTestEngine::MoveFileL(const TDesC &anOld, const TDesC &aNew)
  4639 {
  4640 	PRINT((_L("CVDecTestEngine::MoveFileL, In") ))
  4641 
  4642 	CFileMan* fileman = CFileMan::NewL(iFs);
  4643 	iMemAlloc++;
  4644 	#ifdef __MEM_CHECK_
  4645 	PRINT((_L("CVDecTestEngine::MoveFileL, mem alloc, fileman") ))
  4646 	#endif
  4647 	PRINT((_L("CVDecTestEngine::MoveFileL, fileman [%x]"), fileman))
  4648 
  4649 	CloseFile();
  4650 
  4651 	PRINT((_L("CVDecTestEngine::MoveFileL, File [%s] moving to [%s]"), &anOld, &aNew ))
  4652 	fileman->Move(anOld, aNew);
  4653 
  4654 	PRINT((_L("CVDecTestEngine::MoveFileL, File [%s] moved to [%s]"), &anOld, &aNew ))
  4655 
  4656 	delete fileman;
  4657 	iMemDelete++;
  4658 	#ifdef __MEM_CHECK_
  4659 	PRINT((_L("CVDecTestEngine::MoveFileL, mem del, fileman") ))
  4660 	#endif
  4661 	PRINT((_L("CVDecTestEngine::MoveFileL, Out") ))
  4662 
  4663 	return KErrNone;
  4664 }
  4665 
  4666 /* ----------------------------------------------------------------------------
  4667 * Name:       CVDecTestEngine::CopyFileL()
  4668 * Purpose:
  4669 * Note:
  4670 * Parameters: None
  4671 * Return:     None
  4672 * --------------------------------------------------------------------------*/
  4673 TInt CVDecTestEngine::CopyFileL(const TDesC &anOld, const TDesC &aNew)
  4674 {
  4675 	PRINT((_L("CVDecTestEngine::CopyFileL, In") ))
  4676 
  4677 	CFileMan* fileman = CFileMan::NewL(iFs);
  4678 	iMemAlloc++;
  4679 	#ifdef __MEM_CHECK_
  4680 	PRINT((_L("CVDecTestEngine::MoveFileL, mem alloc, fileman") ))
  4681 	#endif
  4682 	PRINT((_L("CVDecTestEngine::CopyFileL, fileman [%x]"), fileman))
  4683 
  4684 	//CloseFile();
  4685 
  4686 	PRINT((_L("CVDecTestEngine::CopyFileL, File [%s] copying to [%s]"), &anOld, &aNew ))
  4687 	fileman->Copy(anOld, aNew);
  4688 
  4689 	PRINT((_L("CVDecTestEngine::CopyFileL, File [%s] copied to [%s]"), &anOld, &aNew ))
  4690 
  4691 	delete fileman;
  4692 	iMemDelete++;
  4693 	#ifdef __MEM_CHECK_
  4694 	PRINT((_L("CVDecTestEngine::CopyFileL, mem del, fileman") ))
  4695 	#endif
  4696 	PRINT((_L("CVDecTestEngine::CopyFileL, Out") ))
  4697 
  4698 	return KErrNone;
  4699 }
  4700 
  4701 /* ----------------------------------------------------------------------------
  4702 * Name:       CVDecTestEngine::HandleNewBufferL()
  4703 * Purpose:    Get Next input data
  4704 * Note:
  4705 * Parameters: None
  4706 * Return:     None
  4707 * --------------------------------------------------------------------------*/
  4708 
  4709 
  4710 void CVDecTestEngine::HandleNewBufferL()
  4711 {
  4712 
  4713 	if ( iState == ERunning && !iInputEnd )
  4714 	{
  4715 		if ( iDecHWDevId || iCIBuffMgmtOn ) //Retrieve buffer from Hwdevice
  4716 		{
  4717 			GetInputBufferL();
  4718 		}
  4719 		else
  4720 		{
  4721 			FillAndSendBufferL();   // Postproc input
  4722 		}
  4723 
  4724 	}
  4725 	else
  4726 	{
  4727 		PRINT((_L("CVDecTestEngine::HandleNewBufferL, inputEnd found") ))
  4728 		if (iLastFrame)
  4729 		{
  4730 			PRINT((_L("CVDecTestEngine::HandleNewBufferL, Getting last input buffer") ))
  4731 			GetInputBufferL();
  4732 		}
  4733 	}
  4734 
  4735 }
  4736 
  4737 /* ----------------------------------------------------------------------------
  4738 * Name:       CVDecTestEngine::LoadNextFrameL()
  4739 * Purpose:
  4740 * Note:
  4741 * Parameters: None
  4742 * Return:     None
  4743 * --------------------------------------------------------------------------*/
  4744 
  4745 TInt CVDecTestEngine::LoadNextFrameL(TVideoInputBuffer* aCodedInBuffer)
  4746 {
  4747 	// Normal VC1 video reading
  4748 	// Read file after the file header
  4749 	PRINT((_L("CVDecTestEngine::LoadNextFrameL, In")));
  4750 	unsigned int frameDataSize = 4;     //4 Bytes to obain the framesize
  4751 	unsigned int frameSize=0;
  4752 	unsigned int Timestamp;
  4753 	TInt err = 0;
  4754 	TUint8* ptr = new (ELeave) TUint8[frameDataSize]; // dynamic alloc 1
  4755 	iMemAlloc++;
  4756 	#ifdef __MEM_CHECK_
  4757 	PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem alloc, ptr") ))
  4758 	#endif
  4759 	TPtr8 frameData(ptr, frameDataSize);
  4760 	if ( (err = iInFile.Read(frameData, frameDataSize)) != KErrNone)
  4761 	{
  4762 		PRINT((_L("CVDecTestEngine::LoadNextFrameL, Error reading file") ))
  4763 		delete ptr;
  4764 		ptr = NULL;
  4765 		iMemDelete++;
  4766 		#ifdef __MEM_CHECK_
  4767 		PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem del, ptr") ))
  4768 		#endif
  4769 
  4770 		return err;
  4771 	}
  4772 
  4773 	if (frameData.Length() < 4)
  4774 	{
  4775 		PRINT((_L("CVDecTestEngine::LoadNextFrameL, File end found") ))
  4776 		aCodedInBuffer->iData.SetLength( 0 );
  4777 		iInputEnd = ETrue;
  4778 		delete ptr;
  4779 		ptr = NULL;
  4780 		iMemDelete++;
  4781 		#ifdef __MEM_CHECK_
  4782 		PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem del, ptr") ))
  4783 		#endif
  4784 		return KErrNone;
  4785 	}
  4786 
  4787 	PRINT((_L("CVDecTestEngine::LoadNextFrameL, Reading Item") ))
  4788 	ReadItemLE(ptr, 4, (TUint8 *)&frameSize);
  4789 	PRINT((_L("CVDecTestEngine::LoadNextFrameL, before AND frameSize: %x"), frameSize ))
  4790 
  4791 	if (frameData.Length() < 4)
  4792 	{
  4793 		PRINT((_L("CVDecTestEngine::LoadNextFrameL, File end found") ))
  4794 		iInputEnd = ETrue;
  4795 		delete ptr;
  4796 		ptr = NULL;
  4797 		iMemDelete++;
  4798 		#ifdef __MEM_CHECK_
  4799 		PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem del, ptr") ))
  4800 		#endif
  4801 		return KErrNone;
  4802 	}
  4803 
  4804 	//RCV_V2_FRAMESIZE_FLAGS
  4805 	frameSize = frameSize & ~(0xff000000);
  4806 
  4807 	PRINT((_L("CVDecTestEngine::LoadNextFrameL, frameSize: %d"), frameSize ))
  4808 
  4809 	//Now obtain the Timestamp of the frame
  4810 	if ( (err = iInFile.Read(frameData, frameDataSize)) != KErrNone)
  4811 	{
  4812 		PRINT((_L("CVDecTestEngine::LoadNextFrameL, Error reading file %d"), err ))
  4813 		return err;
  4814 	}
  4815 
  4816 	PRINT((_L("CVDecTestEngine::LoadNextFrameL, Reading Item2") ))
  4817 	ReadItemLE(ptr, 4, (TUint8 *)&Timestamp);
  4818 	PRINT((_L("CVDecTestEngine::LoadNextFrameL, Timestamp: %d"), Timestamp ))
  4819 
  4820 	delete ptr;
  4821 	ptr = NULL;
  4822 	iMemDelete++;
  4823 	#ifdef __MEM_CHECK_
  4824 	PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem del, ptr") ))
  4825 	#endif
  4826 
  4827 	if (frameSize != 0)
  4828 	{
  4829 
  4830 		tempFrame += frameSize + 8;
  4831 		PRINT((_L("CVDecTestEngine::LoadNextFrameL, tota data %d"), tempFrame ))
  4832 		PRINT((_L("CVDecTestEngine::LoadNextFrameL, frame"), iFrame))
  4833 
  4834 		TInt currentPos = 0;
  4835 		iInFile.Seek(ESeekCurrent, currentPos );
  4836 		PRINT((_L("CVDecTestEngine::LoadNextFrameL, currentPos %d"), currentPos ))
  4837 		currentPos = 0;
  4838 
  4839 		//Send metadata in the first frame
  4840 		if (iFrame==0)
  4841 		{
  4842 			TInt pos = 0;
  4843 			//err = iInFile.Seek(ESeekCurrent,pos);
  4844 			err = iInFile.Seek(ESeekStart,pos);
  4845 			//        	pos -= 44; //header (36) and framesize+timestamp (8)
  4846 			//        	err = iInFile.Seek(ESeekCurrent,pos);
  4847 			PRINT((_L("CVDecTestEngine::LoadNextFrameL, first frame")))
  4848 			if ( (err = iInFile.Read(aCodedInBuffer->iData, frameSize+44)) != KErrNone)
  4849 			{
  4850 				PRINT((_L("CVDecTestEngine::LoadNextFrameL, Error reading file %d"), err ))
  4851 				return err;
  4852 			}
  4853 
  4854 			TUint8* ptr2 = new(ELeave)TUint8[4];       // dynamic alloc 2
  4855 			iMemAlloc++;
  4856 			#ifdef __MEM_CHECK_
  4857 			PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem alloc, ptr2") ))
  4858 			#endif
  4859 			Mem::FillZ(ptr2,4);
  4860 			TPtr8 firstPtr(ptr2,4,4);
  4861 			//			aCodedInBuffer->iData.Insert(35,firstPtr);
  4862 			PRINT((_L("CVDecTestEngine::LoadNextFrameL, frame1"), iFrame))
  4863 			TUint8* ptr = new ( ELeave ) TUint8[8];    // dynamic alloc 3
  4864 			iMemAlloc++;
  4865 			#ifdef __MEM_CHECK_
  4866 			PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem alloc, ptr") ))
  4867 			#endif
  4868 
  4869 			Mem::FillZ( ptr, 8 );
  4870 			ptr[0] = 1;
  4871 			ptr[4] = 44;
  4872 			TPtr8 anotherPtr(ptr, 8, 8);
  4873 			aCodedInBuffer->iData.Insert(0, anotherPtr );
  4874 			delete ptr2;
  4875 			ptr2 = NULL;
  4876 			delete ptr;
  4877 			ptr = NULL;
  4878 			iMemDelete += 2;
  4879 			#ifdef __MEM_CHECK_
  4880 			PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem del, ptr2 & ptr") ))
  4881 			#endif
  4882 		}
  4883 		else
  4884 		{
  4885 			PRINT((_L("CVDecTestEngine::LoadNextFrameL, iFrame num != 0: %d"), iFrame ))
  4886 			TInt pos = -8;
  4887 
  4888 			err = iInFile.Seek(ESeekCurrent, pos);
  4889 			PRINT((_L("CVDecTestEngine::LoadNextFrameL, read file: %d"), err ))
  4890 			if ( (err = iInFile.Read(aCodedInBuffer->iData, frameSize+8)) != KErrNone)
  4891 			{
  4892 				PRINT((_L("CVDecTestEngine::LoadNextFrameL, Error reading file %d"), err ))
  4893 				return err;
  4894 			}
  4895 
  4896 			TUint8* ptr2 = new(ELeave)TUint8[4];         // dynamic alloc 4
  4897 			iMemAlloc++;
  4898 			#ifdef __MEM_CHECK_
  4899 			PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem alloc, ptr2") ))
  4900 			#endif
  4901 			Mem::FillZ(ptr2,4);
  4902 			TPtr8 firstPtr(ptr2,4,4);
  4903 			//			aCodedInBuffer->iData.Insert(0, firstPtr);
  4904 			delete ptr2;
  4905 			iMemDelete++;
  4906 			#ifdef __MEM_CHECK_
  4907 			PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem del, ptr2") ))
  4908 			#endif
  4909 		}
  4910 
  4911 		TInt substreamID = 0;
  4912 		if(aCodedInBuffer->iUser != NULL){
  4913 			*((TInt*)aCodedInBuffer->iUser) = substreamID;
  4914 		}
  4915 		iInFile.Seek(ESeekCurrent, currentPos );
  4916 		PRINT((_L("CVDecTestEngine::LoadNextFrameL, currentPos %d"), currentPos ))
  4917 		currentPos = 0;
  4918 
  4919 		aCodedInBuffer->iSequenceNumber = iFrame;
  4920 		aCodedInBuffer->iOptions = TVideoInputBuffer::EPresentationTimestamp;
  4921 
  4922 		aCodedInBuffer->iPresentationTimestamp = Timestamp;
  4923 		iTimeToPlay = aCodedInBuffer->iPresentationTimestamp ;
  4924 
  4925 
  4926 		aCodedInBuffer->iDecodingTimestamp = Timestamp;
  4927 		iPresentationTimestamp = aCodedInBuffer->iPresentationTimestamp ;
  4928 
  4929 
  4930 
  4931 	}
  4932 	iFrame++;
  4933 	PRINT(_L("CVDecTestEngine::LoadNextFrameL.. Out"));
  4934 	return frameSize;
  4935 }
  4936 
  4937 
  4938 /* ----------------------------------------------------------------------------
  4939 * Name:       CVDecTestEngine::ReadItemLE()
  4940 * Purpose:
  4941 * Note:
  4942 * Parameters: None
  4943 * Return:     None
  4944 * --------------------------------------------------------------------------*/
  4945 //Currently Supporting only upto 4Bytes
  4946 TBool CVDecTestEngine::ReadItemLE(unsigned char *readBuffer, int Size,
  4947 unsigned char* pItem)
  4948 {
  4949 	PRINT((_L("CVDecTestEngine::ReadItemLE, In")));
  4950 	unsigned int High=0, Low=0;
  4951 	unsigned char m_char;
  4952 	int shift = 0;
  4953 	int numbytes = Size;
  4954 	int i=0;
  4955 
  4956 	/* Read a little-endian file value into a variable, regardless of host endianness */
  4957 	while (numbytes-- >0)
  4958 	{
  4959 		m_char  = readBuffer[i++];
  4960 
  4961 		if (shift >= 32)
  4962 		{
  4963 			High |= m_char << (shift-32);
  4964 		}
  4965 		else
  4966 		{
  4967 			Low  |= m_char << shift;
  4968 		}
  4969 		shift += 8;
  4970 	}
  4971 
  4972 	switch (Size)
  4973 	{
  4974 		case 1:
  4975 		*pItem = (unsigned char)Low;
  4976 		break;
  4977 
  4978 		case 2:
  4979 		*(unsigned short *)pItem = (unsigned short)Low;
  4980 		break;
  4981 
  4982 		case 4:
  4983 		*(unsigned int *)pItem = (unsigned int)Low;
  4984 		break;
  4985 
  4986 		default:
  4987 		//WARN("Unknown size (%d) item read requested",Size);
  4988 		//return false;
  4989 		return EFalse;
  4990 	}
  4991 
  4992 	PRINT((_L("CVDecTestEngine::ReadItemLE, Out")));
  4993 	return TRUE;
  4994 }
  4995 
  4996 /* ----------------------------------------------------------------------------
  4997 * Name:       CVDecTestEngine::GoBackInFile()
  4998 * Purpose:
  4999 * Note:
  5000 * Parameters: None
  5001 * Return:     None
  5002 * --------------------------------------------------------------------------*/
  5003 void CVDecTestEngine::GoBackInFile(TUint aBytes)
  5004 {
  5005 	PRINT((_L("CVDecTestEngine::GoBackInFile, In")));
  5006 
  5007 	//If read pointer is in the end of the buffer change it in the beginning
  5008 	if (iReadDataChunk - iDataChunk >= aBytes)
  5009 	{
  5010 		iReadDataChunk -= aBytes;
  5011 	}
  5012 	else
  5013 	{
  5014 		TInt endBytes = aBytes - (iReadDataChunk - iDataChunk);
  5015 		iReadDataChunk = iDataChunk+iDataChunkSize-endBytes;
  5016 	}
  5017 
  5018 	PRINT((_L("CVDecTestEngine::GoBackInFile, Out, ")));
  5019 }
  5020 
  5021 
  5022 
  5023 /* ----------------------------------------------------------------------------
  5024 * Name:       CVDecTestEngine::ReadByteFromFile()
  5025 * Purpose:
  5026 * Note:
  5027 * Parameters: None
  5028 * Return:     None
  5029 * --------------------------------------------------------------------------*/
  5030 TUint8 CVDecTestEngine::ReadByteFromFile()
  5031 {
  5032 	//PRINT((_L("CVDecTestEngine::ReadByteFromFile, In")));
  5033 	if (iDataReadFromFile == 0)
  5034 	{
  5035 		TInt err = CheckAndFillDataChunk();
  5036 		if (err )
  5037 		{
  5038 			PRINT((_L("CVDecTestEngine::ReadByteFromFile, ERROR [%d]"), err));
  5039 			return 0;
  5040 		}
  5041 	}
  5042 
  5043 	if (iReadDataChunk >= iDataChunk+iDataChunkSize)
  5044 	{
  5045 		iReadDataChunk = iDataChunk;
  5046 	}
  5047 
  5048 	if (iEndOfData && iReadDataChunk == iWriteDataChunk && iDataReadFromFile != 0)
  5049 	{
  5050 		PRINT((_L("CVDecTestEngine::ReadByteFromFile, Input End found")));
  5051 		iInputEnd = ETrue;
  5052 		TUint8 value = 0;
  5053 		return value;
  5054 	}
  5055 
  5056 
  5057 	TUint8 byte = iReadDataChunk[0];
  5058 	iReadDataChunk++;
  5059 	return byte;
  5060 
  5061 }
  5062 
  5063 
  5064 /* ----------------------------------------------------------------------------
  5065 * Name:       CVDecTestEngine::ReadDataToBuffer()
  5066 * Purpose:
  5067 * Note:
  5068 * Parameters: None
  5069 * Return:     None
  5070 * --------------------------------------------------------------------------*/
  5071 void CVDecTestEngine::ReadDataToBuffer(TVideoInputBuffer* aCodedInBuffer, TInt aSize, TBool aDiscard)
  5072 {
  5073 	PRINT((_L("CVDecTestEngine::ReadDataToBuffer, In")));
  5074 	PRINT((_L("CVDecTestEngine::ReadDataToBuffer, iWriteDataChunk [%x]"), iWriteDataChunk));
  5075 	PRINT((_L("CVDecTestEngine::ReadDataToBuffer, iReadDataChunk [%x]"), iReadDataChunk));
  5076 	PRINT((_L("CVDecTestEngine::ReadDataToBuffer, iDataChunk [%x]"), iDataChunk));
  5077 	PRINT((_L("CVDecTestEngine::ReadDataToBuffer, size [%d]"), aSize));
  5078 
  5079 
  5080 
  5081 	TInt err = CheckAndFillDataChunk();
  5082 	if (err )
  5083 	{
  5084 		PRINT((_L("CVDecTestEngine::ReadDataToBuffer, ERROR [%d]"), err));
  5085 		return;
  5086 	}
  5087 
  5088 	aCodedInBuffer->iData.Zero();
  5089 
  5090 	if (iEndOfData)
  5091 	{
  5092 		if (iReadDataChunk == iWriteDataChunk && iDataReadFromFile != 0)
  5093 		{
  5094 			PRINT((_L("CVDecTestEngine::ReadByteFromFile, Input End found")));
  5095 			iInputEnd = ETrue;
  5096 			return;
  5097 		}
  5098 
  5099 		if (iReadDataChunk+aSize > iWriteDataChunk && iReadDataChunk < iWriteDataChunk)
  5100 		{
  5101 			PRINT((_L("CVDecTestEngine::ReadByteFromFile, Input End found")));
  5102 			if (!aDiscard)
  5103 			{
  5104 				aCodedInBuffer->iData.Append(iReadDataChunk, (iWriteDataChunk-iReadDataChunk));
  5105 			}
  5106 			iReadDataChunk += aSize;
  5107 			iInputEnd = ETrue;
  5108 			return;
  5109 		}
  5110 		else if (iReadDataChunk+aSize > iDataChunk+iDataChunkSize && iReadDataChunk > iWriteDataChunk &&
  5111 		iDataChunk+aSize-(iDataChunkSize+iDataChunk-iReadDataChunk) > iWriteDataChunk)
  5112 		{
  5113 			PRINT((_L("CVDecTestEngine::ReadByteFromFile, Input End found")));
  5114 			if (!aDiscard)
  5115 			{
  5116 				aCodedInBuffer->iData.Append(iReadDataChunk, (iDataChunkSize+(iDataChunk-iReadDataChunk)));
  5117 			}
  5118 			iReadDataChunk = iDataChunk;
  5119 			if (!aDiscard)
  5120 			{
  5121 				aCodedInBuffer->iData.Append(iReadDataChunk, (iWriteDataChunk-iReadDataChunk));
  5122 			}
  5123 			iReadDataChunk += iWriteDataChunk-iReadDataChunk;
  5124 			iInputEnd = ETrue;
  5125 			return;
  5126 		}
  5127 	}
  5128 
  5129 	if (iReadDataChunk+aSize <= iDataChunk+iDataChunkSize)
  5130 	{
  5131 		if (!aDiscard)
  5132 		{
  5133 			aCodedInBuffer->iData.Append(iReadDataChunk, aSize);
  5134 		}
  5135 		iReadDataChunk +=aSize;
  5136 	}
  5137 	else if (iReadDataChunk+aSize > iDataChunk+iDataChunkSize)
  5138 	{
  5139 		PRINT((_L("CVDecTestEngine::ReadDataToBuffer, iReadDataChunk+aSize > iDataChunk+iDataChunkSize")));
  5140 		if (!aDiscard)
  5141 		{
  5142 			aCodedInBuffer->iData.Append(iReadDataChunk, (iDataChunkSize+iDataChunk-iReadDataChunk));
  5143 		}
  5144 		TInt end = aSize - ( iDataChunkSize+iDataChunk - iReadDataChunk );
  5145 		iReadDataChunk = iDataChunk;
  5146 		PRINT( ( _L( "CVDecTestEngine::ReadDataToBuffer, iReadDataChunk = iDataChunk") ) );
  5147 		if (!aDiscard)
  5148 		{
  5149 			aCodedInBuffer->iData.Append(iReadDataChunk, end);
  5150 		}
  5151 		iReadDataChunk += end;
  5152 	}
  5153 
  5154 	err = CheckAndFillDataChunk();
  5155 	if (err )
  5156 	{
  5157 		PRINT((_L("CVDecTestEngine::ReadDataToBuffer, ERROR [%d]"), err));
  5158 
  5159 		return;
  5160 	};
  5161 	PRINT((_L("CVDecTestEngine::ReadDataToBuffer, Out")));
  5162 }
  5163 
  5164 /* ----------------------------------------------------------------------------
  5165 * Name:       CVDecTestEngine::CheckAndFillDataChunk()
  5166 * Purpose:
  5167 * Note:
  5168 * Parameters: None
  5169 * Return:     None
  5170 * --------------------------------------------------------------------------*/
  5171 TInt CVDecTestEngine::CheckAndFillDataChunk()
  5172 {
  5173 	PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, In")));
  5174 
  5175 	TInt err = KErrNone;
  5176 
  5177 	//If all the data is read return KerrNone
  5178 	if (iEndOfData)
  5179 	{
  5180 		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, End of data")));
  5181 		return KErrNone;
  5182 	}
  5183 
  5184 	TInt32 read = (TInt32)(iReadDataChunk);
  5185 	TInt32 write = (TInt32)(iWriteDataChunk);
  5186 	TInt32 chunk = (TInt32)(iDataChunkSize);
  5187 	TInt32 thres = (TInt32)(iDataThreshold);
  5188 	//First time fill the whole buffer
  5189 
  5190 	PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, read %d, write %d, chunk %d, thres %d"), read, write, chunk, thres));
  5191 
  5192 	if (iDataReadFromFile == 0)
  5193 	{
  5194 		TPtr8 temp(iWriteDataChunk, iDataChunkSize, iDataChunkSize);
  5195 		if ( (err = iInFile.Read(temp, iDataChunkSize)) != KErrNone)
  5196 		{
  5197 			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, Infile read [%d]"), err));
  5198 			return err;
  5199 		}
  5200 		if (temp.Length() < iDataChunkSize)
  5201 		{
  5202 			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, end of file found [%d]"), temp.Length()));
  5203 			if(temp.Length()== 0){
  5204 				PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, Error! Trying to read zero-sized input file")));
  5205 				iInputEnd = ETrue;
  5206 			}
  5207 			iEndOfData = ETrue;
  5208 			iWriteDataChunk += temp.Length();
  5209 			iDataReadFromFile += temp.Length();
  5210 			return KErrNone;
  5211 		}
  5212 		iDataReadFromFile += iDataChunkSize;
  5213 		for (TUint i = 0; i < 20; i++)
  5214 		{
  5215 			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, [%x]"), iReadDataChunk[i]));
  5216 		}
  5217 	}
  5218 	else if (((read-write) > (chunk-thres)) && (iSentBuffCount != 0))
  5219 	{
  5220 		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, iReadDataChunk-iWriteDataChunk > iDataChunkSize-iDataThreshold")));
  5221 		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, iWriteDataChunk [%x]"), iWriteDataChunk));
  5222 		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, iReadDataChunk [%x]"), iReadDataChunk));
  5223 		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, iDataChunk [%x]"), iDataChunk));
  5224 		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, iReadDataChunk-iWriteDataChunk [%d]"), iReadDataChunk-iWriteDataChunk));
  5225 		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, iDataChunkSize-iDataThreshold [%d]"), iDataChunkSize-iDataThreshold));
  5226 
  5227 		TPtr8 temp(iWriteDataChunk, iReadDataChunk-iWriteDataChunk, iReadDataChunk-iWriteDataChunk);
  5228 		if ( (err = iInFile.Read(temp, (iReadDataChunk-iWriteDataChunk))) != KErrNone)
  5229 		{
  5230 			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, Infile read [%d]"), err));
  5231 			return err;
  5232 		}
  5233 		if (temp.Length() < iReadDataChunk-iWriteDataChunk)
  5234 		{
  5235 			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, End of file found [%d]"), temp.Length()));
  5236 			iEndOfData = ETrue;
  5237 			iWriteDataChunk += temp.Length();
  5238 			return KErrNone;
  5239 		}
  5240 		iWriteDataChunk += iReadDataChunk-iWriteDataChunk;
  5241 		iDataReadFromFile += iReadDataChunk-iWriteDataChunk;
  5242 	}
  5243 	else if (((write-read) < thres) && (iSentBuffCount != 0) && ((write-read) > 0))
  5244 	{
  5245 		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, iReadDataChunk-iWriteDataChunk > -iDataThreshold")));
  5246 		//fill end of the buffer
  5247 		TPtr8 end(iWriteDataChunk, iDataChunk+iDataChunkSize-iWriteDataChunk, iDataChunk+iDataChunkSize-iWriteDataChunk);
  5248 		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, TPtr created")));
  5249 		if ( (err = iInFile.Read(end, (iDataChunkSize+iDataChunk-iWriteDataChunk))) != KErrNone)
  5250 		{
  5251 			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, Infile read [%d]"), err));
  5252 			return err;
  5253 		}
  5254 		if (end.Length() < (iDataChunkSize+iDataChunk-iWriteDataChunk))
  5255 		{
  5256 			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, End of file found [%d]"), end.Length()));
  5257 			iEndOfData = ETrue;
  5258 			iWriteDataChunk += end.Length();
  5259 			return KErrNone;
  5260 		}
  5261 
  5262 		//fill beginning of the buffer
  5263 		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, end of data chunk filled [%d]"), end.Length()));
  5264 		TPtr8 begin(iDataChunk, iReadDataChunk-iDataChunk, iReadDataChunk-iDataChunk);
  5265 		if ( (err = iInFile.Read(begin, iReadDataChunk-iDataChunk)) != KErrNone)
  5266 		{
  5267 			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, Infile read [%d]"), err));
  5268 			return err;
  5269 		}
  5270 		if (begin.Length() < (iReadDataChunk-iDataChunk))
  5271 		{
  5272 			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, End of file found [%d]"), begin.Length()));
  5273 			iEndOfData = ETrue;
  5274 			iWriteDataChunk = iDataChunk+begin.Length();
  5275 			return KErrNone;
  5276 		}
  5277 		iWriteDataChunk = iDataChunk+begin.Length();
  5278 		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, beginning of data chunk filled [%d]"), begin.Length()));
  5279 		iDataReadFromFile += iDataChunkSize-(iWriteDataChunk-iReadDataChunk);
  5280 	}
  5281 	else if (iWriteDataChunk == iDataChunk+iDataChunkSize)
  5282 	{
  5283 		iWriteDataChunk = iDataChunk;
  5284 	}
  5285 
  5286 	PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, Out")));
  5287 	return err;
  5288 }
  5289 
  5290 /* ----------------------------------------------------------------------------
  5291 * Name:       CVDecTestEngine::PrintUncompressedFormat()
  5292 * Purpose:    Get Next input data
  5293 * Note:
  5294 * Parameters: None
  5295 * Return:     None
  5296 * --------------------------------------------------------------------------*/
  5297 
  5298 
  5299 void CVDecTestEngine::PrintUncompressedFormat(const TUncompressedVideoFormat& aFormat)
  5300 {
  5301 	PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, In")))
  5302 
  5303 	switch (aFormat.iDataFormat)
  5304 	{
  5305 		case ERgbRawData:
  5306 		PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iDataFormat = ERgbRawData")))
  5307 		case ERgbFbsBitmap:
  5308 		PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iDataFormat = ERgbFbsBitmap")))
  5309 		switch(aFormat.iRgbFormat)
  5310 		{
  5311 			case ERgb16bit444:
  5312 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iRgbFormat = ERgb16bit444")))
  5313 			break;
  5314 			case ERgb16bit565:
  5315 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iRgbFormat = ERgb16bit565")))
  5316 			break;
  5317 			case ERgb32bit888:
  5318 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iRgbFormat = ERgb32bit888")))
  5319 			break;
  5320 			case EFbsBitmapColor4K:
  5321 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iRgbFormat = EFbsBitmapColor4K")))
  5322 			break;
  5323 			case EFbsBitmapColor64K:
  5324 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iRgbFormat = EFbsBitmapColor64K")))
  5325 			break;
  5326 			case EFbsBitmapColor16M:
  5327 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iRgbFormat = EFbsBitmapColor16M")))
  5328 			break;
  5329 			case EFbsBitmapColor16MU:
  5330 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iRgbFormat = EFbsBitmapColor16MU")))
  5331 			break;
  5332 			default:
  5333 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, Error reading iRgbFormat [%x]"), aFormat.iRgbFormat))
  5334 		}
  5335 		break;
  5336 		case EYuvRawData:
  5337 		PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iDataFormat = EYuvRawData")))
  5338 		switch(aFormat.iYuvFormat.iCoefficients)
  5339 		{
  5340 			case EYuvRange0:
  5341 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = EYuvRange0")))
  5342 			break;
  5343 			case EYuvRange1:
  5344 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = EYuvRange1")))
  5345 			break;
  5346 			case EYuvBt709:
  5347 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = EYuvBt709")))
  5348 			break;
  5349 			case EYuvBt709Range0:
  5350 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = EYuvBt709Range0")))
  5351 			break;
  5352 			case EYuvBt709Range1:
  5353 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = EYuvBt709Range1")))
  5354 			break;
  5355 			case EYuvBt601:
  5356 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = EYuvBt601")))
  5357 			break;
  5358 			case EYuvBt601Range0:
  5359 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = EYuvBt601Range0")))
  5360 			break;
  5361 			case EYuvBt601Range1:
  5362 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = EYuvBt601Range1")))
  5363 			break;
  5364 			case ECustomYuvMatrix:
  5365 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = ECustomYuvMatrix")))
  5366 			break;
  5367 			default:
  5368 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, Error reading iCoefficients [%x]"), aFormat.iYuvFormat.iCoefficients))
  5369 		}
  5370 		switch(aFormat.iYuvFormat.iPattern)
  5371 		{
  5372 			case EYuv420Chroma1:
  5373 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iPattern = EYuv420Chroma1")))
  5374 			break;
  5375 			case EYuv420Chroma2:
  5376 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iPattern = EYuv420Chroma2")))
  5377 			break;
  5378 			case EYuv420Chroma3:
  5379 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iPattern = EYuv420Chroma3")))
  5380 			break;
  5381 			case EYuv422Chroma1:
  5382 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iPattern = EYuv422Chroma1")))
  5383 			break;
  5384 			case EYuv422Chroma2:
  5385 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iPattern = EYuv422Chroma2")))
  5386 			break;
  5387 			default:
  5388 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, Error reading iPattern [%x]"), aFormat.iYuvFormat.iPattern))
  5389 		}
  5390 		switch(aFormat.iYuvFormat.iDataLayout)
  5391 		{
  5392 			case EYuvDataPlanar:
  5393 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iDataLayout = EYuvDataPlanar")))
  5394 			break;
  5395 			case EYuvDataInterleavedLE:
  5396 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iDataLayout = EYuvDataInterleavedLE")))
  5397 			break;
  5398 			case EYuvDataInterleavedBE:
  5399 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iDataLayout = EYuvDataInterleavedBE")))
  5400 			break;
  5401 			case EYuvDataSemiPlanar:
  5402 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iDataLayout = EYuvDataSemiPlanar")))
  5403 			break;
  5404 			default:
  5405 			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, Error reading iDataLayout [%x]"), aFormat.iYuvFormat.iDataLayout))
  5406 		}
  5407 		PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iAspectRatioNum [%d]"), aFormat.iYuvFormat.iAspectRatioNum))
  5408 		PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iAspectRatioDenom [%d]"), aFormat.iYuvFormat.iAspectRatioDenom))
  5409 		break;
  5410 		default :
  5411 		PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, Error reading iDataFormat [%x]"), aFormat.iDataFormat))
  5412 	}
  5413 
  5414 	PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, Out")))
  5415 }
  5416 
  5417 /* ----------------------------------------------------------------------------
  5418 * Name:       CVDecTestEngine::ConvertToRealL()
  5419 * Purpose:    Converts the given descriptor to TReal
  5420 * Parameters: const TDesC& aPtr
  5421 * Return:     TReal
  5422 * --------------------------------------------------------------------------*/
  5423 
  5424 TReal CVDecTestEngine::ConvertToRealL(const TDesC& aPtr)
  5425 {
  5426 	PRINT((_L("CVDecTestEngine::ConvertToReal(),In")))
  5427 
  5428 	TInt point = aPtr.Find(_L("."));
  5429 
  5430 	TBufC<7> integer;
  5431 	TBufC<7> decimal;
  5432 	if (point != KErrNotFound)
  5433 	{
  5434 
  5435 		integer = aPtr.Mid(0, point);
  5436 		decimal = aPtr.Mid(point+1);
  5437 	}
  5438 	else
  5439 	{
  5440 		User::Leave(KErrArgument);
  5441 	}
  5442 	TInt decimalInt = 0;
  5443 	TInt integerInt = 0;
  5444 	TLex lexInt(integer);
  5445 	TLex lexDec(decimal);
  5446 
  5447 	if (lexInt.Val(integerInt) != KErrNone || lexDec.Val(decimalInt) != KErrNone)
  5448 	{
  5449 		PRINT((_L("CVDecTestEngine::ConvertToReal(), error in descriptor")))
  5450 		User::Leave(KErrArgument);
  5451 	}
  5452 
  5453 
  5454 	TReal real = 1.0;
  5455 	TReal length = static_cast<TReal>(aPtr.Length()-point-1);
  5456 	TReal denom = pow(10.0, length);
  5457 
  5458 
  5459 	real = (static_cast<TReal>(integerInt)) + (static_cast<TReal>(decimalInt)/denom);
  5460 
  5461 	PRINT((_L("CVDecTestEngine::ConvertToReal(),integer [%d]"), integerInt))
  5462 	PRINT((_L("CVDecTestEngine::ConvertToReal(),decimal [%d]"), decimalInt))
  5463 	PRINT((_L("CVDecTestEngine::ConvertToReal(),denom [%f]"), denom))
  5464 	PRINT((_L("CVDecTestEngine::ConvertToReal(),real [%f]"), real))
  5465 
  5466 	PRINT((_L("CVDecTestEngine::ConvertToReal(),Out")))
  5467 	return real;
  5468 }
  5469 
  5470 
  5471 /* ----------------------------------------------------------------------------
  5472 * Name:       CVDecTestEngine::MdvpoNewBuffers()
  5473 * Purpose:    Availability of Next buffer is notified
  5474 * Note:
  5475 * Parameters: None
  5476 * Return:     None
  5477 * --------------------------------------------------------------------------*/
  5478 
  5479 
  5480 void CVDecTestEngine::MdvpoNewBuffers()
  5481 {
  5482 	PRINT((_L("CVDecTestEngine::MdvpoNewBuffers(), Newbuffer is available")))
  5483 
  5484 	//if ( iFrameMeasurement )
  5485 	//    return;
  5486 
  5487 	if ( iState == ERunning)
  5488 	{
  5489 		iDecTestAO->RequestData();
  5490 	}
  5491 
  5492 
  5493 }
  5494 
  5495 /* ----------------------------------------------------------------------------
  5496 * Name:       CVDecTestEngine::MdvpoReturnPicture()
  5497 * Purpose:    Postprocessor Input buffer is returned
  5498 * Note:       Used when input to Postprocessing
  5499 * Parameters: TVideoPicture* aPicture
  5500 * Return:     None
  5501 * --------------------------------------------------------------------------*/
  5502 
  5503 
  5504 void CVDecTestEngine::MdvpoReturnPicture(TVideoPicture* aPicture)
  5505 {
  5506 	if ( iRawInBuffer == aPicture )
  5507 	{
  5508 		PRINT((_L("CVDecTestEngine::MdvpoReturnPicture, a Picture returned ")))
  5509 		iDecTestAO->RequestData();
  5510 
  5511 	}
  5512 	else
  5513 	{
  5514 		PRINT((_L("CVDecTestEngine::MdvpoReturnPicture, Returned picture unknown")))
  5515 		iError = KErrGeneral;
  5516 	}
  5517 }
  5518 
  5519 
  5520 
  5521 /* ----------------------------------------------------------------------------
  5522 * Name:       CVDecTestEngine::MdvpoSupplementalInformation()
  5523 * Purpose:    Supplementary information is notified
  5524 * Note:
  5525 * Parameters: const TDesC8& aData, const TTimeIntervalMicroSeconds& aTimestamp, const TPictureId& aPictureId
  5526 * Return:     None
  5527 * --------------------------------------------------------------------------*/
  5528 
  5529 
  5530 void CVDecTestEngine::MdvpoSupplementalInformation(const TDesC8& /*aData*/, const TTimeIntervalMicroSeconds& /*aTimestamp*/, const TPictureId& /*aPictureId*/)
  5531 {
  5532 	PRINT((_L("CVDecTestEngine::MdvpoSupplementalInformation  ")))
  5533 }
  5534 
  5535 
  5536 /* ----------------------------------------------------------------------------
  5537 * Name:       CVDecTestEngine::MdvpoPictureLoss()
  5538 * Purpose:    Loss of a picture is notified
  5539 * Note:
  5540 * Parameters: None
  5541 * Return:     None
  5542 * --------------------------------------------------------------------------*/
  5543 
  5544 void CVDecTestEngine::MdvpoPictureLoss()
  5545 {
  5546 	iPictureLoss++;
  5547 	PRINT((_L("CVDecTestEngine::MdvpoPictureLoss, A picture lost. ")))
  5548 
  5549 }
  5550 
  5551 
  5552 /* ----------------------------------------------------------------------------
  5553 * Name:       CVDecTestEngine::MdvpoPictureLoss()
  5554 * Purpose:    Loss of pictures is notified
  5555 * Note:
  5556 * Parameters: const TArray<TPictureId>& aPictures
  5557 * Return:     None
  5558 * --------------------------------------------------------------------------*/
  5559 
  5560 void CVDecTestEngine::MdvpoPictureLoss(const TArray<TPictureId>& aPictures)
  5561 {
  5562 	TInt count = aPictures.Count();
  5563 	iPictureLoss += count;
  5564 	PRINT((_L("CVDecTestEngine::MdvpoPictureLoss, [%d] pictures lost. "),count))
  5565 
  5566 	for ( TInt i =0; i<count;i++ )
  5567 	{
  5568 		TPictureId id = aPictures[i];
  5569 		PRINT((_L("CVDecTestEngine::MdvpoPictureLoss, Picure:[%d]"),i))
  5570 
  5571 		/*       if(id.iIdType == TPictureId::EPictureNumber)
  5572 		PRINT((_L("CVDecTestEngine::MdvpoPictureLoss, Picture Type:Picture Number, ID:[%d]"),id.iId))
  5573 		else if (id.iIdType == TPictureId::ETemporalReference)
  5574 		PRINT((_L("CVDecTestEngine::MdvpoPictureLoss, Picture Type:Temporal Reference, ID:[%d]"),id.iId))
  5575 		else
  5576 		PRINT((_L("CVDecTestEngine::MdvpoPictureLoss, Picture Type:Unidentified piture")))
  5577 		*/
  5578 	}
  5579 }
  5580 
  5581 /* ----------------------------------------------------------------------------
  5582 * Name:       CVDecTestEngine::MdvpoSliceLoss
  5583 * Purpose:    Loss of slice is notified
  5584 * Note:
  5585 * Parameters: TUint aFirstMacroblock, TUint aNumMacroblocks, const TPictureId& aPicture
  5586 * Return:     None
  5587 * --------------------------------------------------------------------------*/
  5588 
  5589 void CVDecTestEngine::MdvpoSliceLoss(TUint /*aFirstMacroblock*/, TUint /*aNumMacroblocks*/, const TPictureId& /*aPicture*/)
  5590 {
  5591 
  5592 	PRINT((_L("CVDecTestEngine::MdvpoSliceLoss, In")))
  5593 
  5594 	//    PRINT((_L("CVDecTestEngine::MdvpoSliceLoss, [%d] consecutive Mactoblocks from [%d] in raster-scan order are lost"),aPicture.aNumMacroblocks ,aPicture.aFirstMacroblock))
  5595 	/*    if( aPicture.iIdType == TPictureId::EPictureNumber)
  5596 	PRINT((_L("CVDecTestEngine::MdvpoSliceLoss, Picture Type:Picture Number, ID:[%d]"),aPicture.iId))
  5597 	else if (aPicture.iIdType == TPictureId::ETemporalReference)
  5598 	PRINT((_L("CVDecTestEngine::MdvpoSliceLoss, Picture Type:Temporal Reference, ID:[%d]"),aPicture.iId))
  5599 	else
  5600 	PRINT((_L("CVDecTestEngine::MdvpoSliceLoss, Picture Type:Unidentified piture")))
  5601 	*/
  5602 
  5603 }
  5604 
  5605 
  5606 /* ----------------------------------------------------------------------------
  5607 * Name:       CVDecTestEngine::MdvpoReferencePictureSelection
  5608 * Purpose:
  5609 * Note:
  5610 * Parameters: const TDesC8& aSelectionData
  5611 * Return:     None
  5612 * --------------------------------------------------------------------------*/
  5613 
  5614 
  5615 void CVDecTestEngine::MdvpoReferencePictureSelection(const TDesC8& /*aSelectionData*/)
  5616 {
  5617 	PRINT((_L("CVDecTestEngine::MdvpoReferencePictureSelection ")))
  5618 
  5619 }
  5620 
  5621 /* ----------------------------------------------------------------------------
  5622 * Name:       CVDecTestEngine::MdvpoTimedSnapshotComplete()
  5623 * Purpose:
  5624 * Note:
  5625 * Parameters: TInt aError, TPictureData* aPictureData, const TTimeIntervalMicroSeconds& aPresentationTimestamp, const TPictureId& aPictureId
  5626 * Return:     None
  5627 * --------------------------------------------------------------------------*/
  5628 
  5629 void CVDecTestEngine::MdvpoTimedSnapshotComplete(TInt aError, TPictureData* aPictureData, const TTimeIntervalMicroSeconds& /*aPresentationTimestamp*/, const TPictureId& aPictureId)
  5630 {
  5631 	PRINT((_L("CVDecTestEngine::MdvpoTimedSnapshotComplete(),In, error [%d]"), aError))
  5632 
  5633 	if ( aError == KErrNone )
  5634 	{
  5635 		RFile snapshot;
  5636 
  5637 		TFileName filename;
  5638 		TBuf8<128> newFile;
  5639 		newFile.Delete(newFile.Length()-5, 4);
  5640 		newFile.Append(_L("_id_"));
  5641 		newFile.AppendNum(aPictureId.iId);
  5642 		newFile.Append(_L(".yuv"));
  5643 		filename.Copy(newFile);
  5644 
  5645 		TInt err = snapshot.Replace(iFs, filename, EFileShareExclusive|EFileWrite);
  5646 
  5647 		if ( err != KErrNone )
  5648 		{
  5649 			PRINT((_L("CVDecTestEngine::GetSnapshotL, snapshot file open failed")))
  5650 			snapshot.Close();
  5651 			User::Leave(err);
  5652 		}
  5653 		else
  5654 		{
  5655 			err = snapshot.Write(*(aPictureData->iRawData),aPictureData->iRawData->Size());
  5656 			if ( err!= KErrNone )
  5657 			{
  5658 				PRINT((_L("CVDecTestEngine::GetSnapshotL, snapshot file write failed")))
  5659 				snapshot.Close();
  5660 				User::Leave(err);
  5661 			}
  5662 		}
  5663 		PRINT((_L("CVDecTestEngine::GetSnapshotL, Picture size"),aPictureData->iRawData->Size()));
  5664 		snapshot.Close();
  5665 	}
  5666 	PRINT((_L("CVDecTestEngine::MdvpoTimedSnapshotComplete(),Out")))
  5667 }
  5668 
  5669 
  5670 /* ----------------------------------------------------------------------------
  5671 * Name:       CVDecTestEngine::MdvpoNewPictures()
  5672 * Purpose:
  5673 * Note:
  5674 * Parameters: None
  5675 * Return:     None
  5676 * --------------------------------------------------------------------------*/
  5677 
  5678 void CVDecTestEngine::MdvpoNewPictures()
  5679 {
  5680 
  5681 	PRINT((_L("CVDecTestEngine::MdvpoNewPictures(),In, New output picture is available")))
  5682 
  5683 	GetReturnedPictureL();
  5684 }
  5685 
  5686 
  5687 
  5688 /* ----------------------------------------------------------------------------
  5689 * Name:       CVDecTestEngine::MdvpoFatalError()
  5690 * Purpose:    Fatal error is notified
  5691 * Note:       Decoder/Postprocessor to be deleted
  5692 * Parameters: TInt aError
  5693 * Return:     None
  5694 * --------------------------------------------------------------------------*/
  5695 
  5696 void CVDecTestEngine::MdvpoFatalError(TInt aError)
  5697 {
  5698 	iError = aError;
  5699 	PRINT((_L("CVDecTestEngine::MdvpoFatalError, FATAL ERROR [%d]"),aError))
  5700 	iState = EStopped;
  5701 	MdvpoStreamEnd();
  5702 
  5703 	iTestClass->MvdeSetError(aError);
  5704 }
  5705 
  5706 
  5707 /* ----------------------------------------------------------------------------
  5708 * Name:       CVDecTestEngine::MdvpoInitComplete()
  5709 * Purpose:    Completion of initialization is notified
  5710 * Note:
  5711 * Parameters: TInt aError
  5712 * Return:     None
  5713 * --------------------------------------------------------------------------*/
  5714 
  5715 void CVDecTestEngine::MdvpoInitComplete(TInt aError)
  5716 {
  5717 	PRINT((_L("CVDecTestEngine::MdvpoInitComplete, In")))
  5718 	if ( iRunning )
  5719 	{
  5720 		PRINT((_L("CVDecTestEngine::MdvpoInitComplete, Stopping SchedulerWait")))
  5721 		iScheduler->AsyncStop();
  5722 		delete iScheduler;
  5723 		iScheduler = NULL;
  5724 		iMemDelete++;
  5725 		#ifdef __MEM_CHECK_
  5726 		PRINT((_L("CVDecTestEngine::MdvpoInitComplete, mem del, iScheduler") ))
  5727 		#endif
  5728 	}
  5729 
  5730 	if ( aError != KErrNone )
  5731 	{
  5732 		iError = aError;
  5733 		PRINT((_L("CVDecTestEngine::MdvpoInitComplete, Error code [%d]"),aError))
  5734 		return;
  5735 	}
  5736 
  5737 	if (iDeleteDecoderFromInitComp)
  5738 	{
  5739 		//TearDown();
  5740 		delete iDevvp;
  5741 		iDevvp = NULL;
  5742 		iMemDelete++;
  5743 		#ifdef __MEM_CHECK_
  5744 		PRINT((_L("CVDecTestEngine::MdvpoInitComplete, mem del, iDevvp") ))
  5745 		#endif
  5746 		iState = EStateNone;
  5747 		PRINT((_L("CVDecTestEngine::MdvpoInitComplete,DevVideo deleted")))
  5748 	}
  5749 
  5750 	iState = EInitialized;
  5751 	PRINT((_L("CVDecTestEngine::MdvpoInitComplete, Initialized")))
  5752 
  5753 	//Initilize parameters for Decoding/Playback
  5754 	iCodedInBuffer = NULL;
  5755 	iOutBuffer =NULL;
  5756 	iSentBuffCount = 0;
  5757 	iReturnedBuffCount = 0;
  5758 	iPictureLoss =0;
  5759 	iInputEnd = EFalse;
  5760 	iStreamEnd = EFalse;
  5761 	iTimeStamp = 0;
  5762 	iNoBuffAvailable = 0;
  5763 
  5764 	iTestClass->MvdeStreamEndReached();  // Notify observer data transfer is complete
  5765 	PRINT((_L("CVDecTestEngine::MdvpoInitComplete, Out")))
  5766 }
  5767 
  5768 
  5769 /* ----------------------------------------------------------------------------
  5770 * Name:       CVDecTestEngine::MdvpoStreamEnd()
  5771 * Purpose:    End of stream is notified
  5772 * Note:
  5773 * Parameters: None
  5774 * Return:     None
  5775 * --------------------------------------------------------------------------*/
  5776 
  5777 void CVDecTestEngine::MdvpoStreamEnd()
  5778 {
  5779 	iStreamEnd = ETrue;
  5780 	if (iOutBufferTemp)
  5781 	{
  5782 		iDevvp->ReturnPicture(iOutBufferTemp);
  5783 	}
  5784 	PRINT((_L("CVDecTestEngine::MdvpoStreamEnd(), Stream end")))
  5785 
  5786 	if (iFrameMeasurement && iFrameTime != 0)
  5787 	{
  5788 		TReal framerate = (TReal)(iReturnedBuffCount-1) / iFrameTime;
  5789 		PRINT((_L("CVDecTestEngine::MdvpoStreamEnd(), Frame rate: [%f] fps"), framerate))
  5790 	}
  5791 	if(iInstantFpsEnabled)
  5792 	{
  5793 		TInt err = KErrNone;
  5794 		for(TUint i=0; i < iInstantFpsList.Count(); i++ )
  5795 		{
  5796 			_LIT(KEnd, "\n");
  5797 			TBuf8 <0x100> tempBuff;
  5798 			TTimeIntervalMicroSeconds time = iInstantFpsList[ i ];
  5799 			tempBuff.AppendNum((TInt64)time.Int64());
  5800 			tempBuff.Append(KEnd);
  5801 			err = iFpsFile.Write(tempBuff,tempBuff.Size() );
  5802 			if( err != KErrNone )
  5803 			{
  5804 				PRINT((_L("CVDecTestEngine::MdvpoStreamEnd(), iFpsFile write error: [%d]"), err))
  5805 			}
  5806 		}
  5807 	}
  5808 	iTestClass->MvdeStreamEndReached();  // Notify observer data transfer is complete
  5809 }
  5810 
  5811 /* ----------------------------------------------------------------------------
  5812 * Name:       CVDecTestEngine::MmvbmoNewBuffers()
  5813 * Purpose:    Observer callback in Custom interface Buffer management
  5814 *             Client is notified a new buffer(s) is available
  5815 * Note:       This is used when custom interface buffer management is used
  5816 * Parameters: None
  5817 * Return:     None
  5818 * --------------------------------------------------------------------------*/
  5819 
  5820 #ifdef __CI_HEADERS__
  5821 
  5822 void CVDecTestEngine::MmvbmoNewBuffers()
  5823 {
  5824 
  5825 	PRINT((_L("CVDecTestEngine::MmvbmoNewBuffers(), New input buffer is available")))
  5826 	if ( (iState == ERunning) && iCIBuffMgmtOn )
  5827 	{
  5828 		iDecTestAO->RequestData();
  5829 	}
  5830 
  5831 }
  5832 #endif
  5833 /* ----------------------------------------------------------------------------
  5834 * Name:       CVDecTestEngine::MmvbmoReleaseBuffers()
  5835 * Purpose:    Observer callback in Custom interface Buffer management
  5836 *             Client is notified to release all buffers it has, using MmvbmReleaseBuffer
  5837 * Note:       This is used when custom interface buffer management is used
  5838 * Parameters: None
  5839 * Return:     None
  5840 * --------------------------------------------------------------------------*/
  5841 #ifdef __CI_HEADERS__
  5842 void CVDecTestEngine::MmvbmoReleaseBuffers()
  5843 {
  5844 	if (iRawInBuffer)
  5845 	{
  5846 		iCIBuffMgmt->MmvbmReleaseBuffer(iRawInBuffer);
  5847 		iRawInBuffer = NULL;
  5848 	}
  5849 	PRINT((_L("CVDecTestEngine::MmvbmoReleaseBuffers(), buffer released")))
  5850 }
  5851 
  5852 #endif
  5853 
  5854 /* ----------------------------------------------------------------------------
  5855 * Name:       CVDecTestEngine::
  5856 * Purpose:
  5857 * Parameters: None
  5858 * Return:     None
  5859 * --------------------------------------------------------------------------*/
  5860 #ifdef __RESOURCENOTIFICATION__
  5861 void CVDecTestEngine::MmvroResourcesLost(TUid aMediaDevice)
  5862 {
  5863 	PRINT((_L("CVDecTestEngine::MmvroResourcesLost(), Uid [%x]"), aMediaDevice.iUid))
  5864 
  5865 	if (iDecoderUid.iUid != aMediaDevice.iUid)
  5866 	{
  5867 		PRINT((_L("CVDecTestEngine::MmvroResourcesLost, UID is different")))
  5868 		return;
  5869 	}
  5870 
  5871 	Pause();
  5872 
  5873 	iDecTestAO->Cancel();
  5874 	if ( iDirectScreenAccess && iDsaStarted )
  5875 	{
  5876 		iDevvp->AbortDirectScreenAccess();
  5877 		iDsaStarted = EFalse;
  5878 		PRINT((_L("CVDecTestEngine::MmvroResourcesLost, DSA is aborted ")))
  5879 	}
  5880 
  5881 
  5882 	PRINT((_L("CVDecTestEngine::MmvroResourcesLost, Out ")))
  5883 }
  5884 #endif
  5885 
  5886 /* ----------------------------------------------------------------------------
  5887 * Name:       CVDecTestEngine::
  5888 * Purpose:
  5889 * Parameters: None
  5890 * Return:     None
  5891 * --------------------------------------------------------------------------*/
  5892 #ifdef __RESOURCENOTIFICATION__
  5893 void CVDecTestEngine::MmvroResourcesRestored(TUid aMediaDevice)
  5894 {
  5895 	PRINT((_L("CVDecTestEngine::MmvroResourcesRestored(), Uid [%x]"), aMediaDevice.iUid))
  5896 
  5897 	if (iDecoderUid.iUid != aMediaDevice.iUid)
  5898 	{
  5899 		PRINT((_L("CVDecTestEngine::MmvroResourcesRestored, UID is different")))
  5900 		return;
  5901 	}
  5902 
  5903 	if ( iDirectScreenAccess && !iDsaStarted )
  5904 	{
  5905 		TRAPD(err, StartDirectScreenAccessL());
  5906 		if (err != KErrNone)
  5907 		{
  5908 			PRINT((_L("CVDecTestEngine::MmvroResourcesRestored, couldn't start DSA, err[%d]"),err))
  5909 			User::Leave(err);
  5910 		}
  5911 		else
  5912 		{
  5913 			PRINT((_L("CVDecTestEngine::MmvroResourcesRestored, DSA started")))
  5914 		}
  5915 	}
  5916 
  5917 
  5918 	// Start DevVideoPlay
  5919 	Resume();
  5920 
  5921 	PRINT((_L("CVDecTestEngine::MmvroResourcesRestored(), Out")))
  5922 }
  5923 
  5924 #endif
  5925 
  5926 /* ----------------------------------------------------------------------------
  5927 * Name:       CVDecTestAO::CVDecTestAO()
  5928 * Purpose:    Constructor
  5929 * Parameters: CVDecTestEngine* aTestEngine
  5930 * Return:     None
  5931 * --------------------------------------------------------------------------*/
  5932 
  5933 CVDecTestAO::CVDecTestAO(CVDecTestEngine* aTestEngine) :
  5934 CActive(EPriorityStandard)
  5935 {
  5936 	iTestEngine = aTestEngine;
  5937 	CActiveScheduler::Add(this);
  5938 
  5939 }
  5940 
  5941 
  5942 /* ----------------------------------------------------------------------------
  5943 * Name:       CVDecTestAO::~CVDecTestAO()
  5944 * Purpose:    Deconstructor
  5945 * Parameters: None
  5946 * Return:     None
  5947 * --------------------------------------------------------------------------*/
  5948 
  5949 CVDecTestAO::~CVDecTestAO()
  5950 {
  5951 
  5952 	Cancel();
  5953 
  5954 }
  5955 
  5956 
  5957 /* ----------------------------------------------------------------------------
  5958 * Name:       CVDecTestAO::RequestData()
  5959 * Purpose:    Asyncronous request of next input data
  5960 * Parameters: None
  5961 * Return:     None
  5962 * --------------------------------------------------------------------------*/
  5963 
  5964 void CVDecTestAO::RequestData()
  5965 {
  5966 
  5967 	if ( !IsActive() )
  5968 	{
  5969 		TRequestStatus* status = &iStatus;
  5970 		User::RequestComplete(status, KErrNone);
  5971 
  5972 		SetActive();
  5973 	}
  5974 	else
  5975 	{
  5976 		PRINT((_L("CVDecTestAO::RequestData(), Async request already active")))
  5977 	}
  5978 }
  5979 
  5980 /* ----------------------------------------------------------------------------
  5981 * Name:       CVDecTestAO::RunL()
  5982 * Purpose:    Active object RunL
  5983 * Parameters: None
  5984 * Return:     None
  5985 * --------------------------------------------------------------------------*/
  5986 
  5987 void CVDecTestAO::RunL()
  5988 {
  5989 	if (iTestEngine->iState == EPaused || iTestEngine->iState == EStopped)
  5990 	{
  5991 		return;
  5992 	}
  5993 	iTestEngine->HandleNewBufferL();
  5994 }
  5995 
  5996 /* ----------------------------------------------------------------------------
  5997 * Name:       CVDecTestAO::DoCancel()
  5998 * Purpose:
  5999 * Parameters: None
  6000 * Return:     None
  6001 * --------------------------------------------------------------------------*/
  6002 
  6003 
  6004 void CVDecTestAO::DoCancel()
  6005 {
  6006 
  6007 }
  6008 
  6009 /* ----------------------------------------------------------------------------
  6010 * Name:       CVDecTestEngine::CorruptInput()
  6011 * Purpose:    Make the input file corrupted to test codec's robustness
  6012 * Note:
  6013 * Parameters: None
  6014 * Return:     None
  6015 * --------------------------------------------------------------------------*/
  6016 
  6017 void CVDecTestEngine::CorruptInput(TInt aFilter, TInt aInterval,
  6018 TInt aFrameNum, TInt aPct)
  6019 {
  6020 	PRINT((_L("CVDecTestEngine::CorruptInput(),In")))
  6021 
  6022 	iCorruptMarker = ETrue;
  6023 	iCorruptCounter = 0;
  6024 
  6025 	iFilter = aFilter;
  6026 	iInterval = aInterval;
  6027 	iFrameNum = aFrameNum;
  6028 	iPercentage = aPct;
  6029 
  6030 	PRINT((_L("CVDecTestEngine::CorruptInput(),Out")))
  6031 }
  6032 
  6033 /* ----------------------------------------------------------------------------
  6034 * Name:       CVDecTestEngine::CorruptEngine()
  6035 * Purpose:    Make the content in the buffer corrupted
  6036 * Note:
  6037 * Parameters:
  6038 * Return:     None
  6039 * --------------------------------------------------------------------------*/
  6040 
  6041 void CVDecTestEngine::CorruptEngineL()
  6042 {
  6043 	PRINT((_L("CVDecTestEngine::CorruptEngin(), In")))
  6044 	if( iInputEnd )
  6045 	{
  6046 		return;
  6047 	}
  6048 	if( iFrameCounter <= iInterval )
  6049 	{
  6050 		if( iFrameCounter < iInterval )
  6051 		{
  6052 			iFrameCounter++;
  6053 			return;
  6054 		}
  6055 		else
  6056 		{
  6057 			iCorruptCounter++;
  6058 		}
  6059 	}
  6060 	else
  6061 	{
  6062 		User::Leave( KErrGeneral);
  6063 	}
  6064 	TInt frameLength = iCodedInBuffer->iData.Size();
  6065 	TInt maxLength = iCodedInBuffer->iData.MaxLength();
  6066 
  6067 	TUint8* memoryLocation = NULL;
  6068 	TPtr8 tmpPointer(memoryLocation, frameLength, maxLength );
  6069 	HBufC8* tempBuff = NULL;
  6070 	tempBuff = HBufC8::NewL(iInBuffSize);
  6071 	CleanupStack::PushL( tempBuff );
  6072 	iMemAlloc++;
  6073 	#ifdef __MEM_CHECK_
  6074 	PRINT((_L("CVDecTestEngine::CorruptEngineL, mem alloc, tempBuff") ))
  6075 	#endif
  6076 	tmpPointer.Set(tempBuff->Des());
  6077 
  6078 	if( iFilter == 0 )
  6079 	{
  6080 		//Filter 0
  6081 		PRINT((_L("CVDecTestEngine::CorruptEngin(),Filter 0, In")))
  6082 
  6083 
  6084 		TInt lengthCopy = (TInt)( frameLength * iPercentage / 100 );
  6085 
  6086 
  6087 		tmpPointer.Set(iCodedInBuffer->iData);
  6088 
  6089 		TInt corruptLength = frameLength - lengthCopy;
  6090 		TInt corruptLen = 0;
  6091 		for( TInt i = 0; i < corruptLength; i++ )
  6092 		{
  6093 			tmpPointer.Append('F');
  6094 			corruptLen++;
  6095 		}
  6096 		PRINT((_L("CVDecTestEngine::CorruptEngin(),[%d] bytes are corrupted"), corruptLen ) )
  6097 		iCodedInBuffer->iData.Set(tmpPointer);
  6098 
  6099 		PRINT((_L("CVDecTestEngine::CorruptEngin(),Filter 0, Out")))
  6100 	}
  6101 	else
  6102 	{
  6103 		// Filter 1
  6104 		PRINT((_L("CVDecTestEngine::CorruptEngin(),Filter 1, In")))
  6105 		// To be added here
  6106 		TInt headerLen = 0;
  6107 		if( iFrame == 0 )
  6108 		{
  6109 			headerLen = 16;
  6110 
  6111 		}
  6112 		else
  6113 		{
  6114 			headerLen = 8;
  6115 		}
  6116 		TInt increment = (TInt)( ( frameLength - headerLen )/ ( ( frameLength - headerLen) * iPercentage / 100) ) - 1;
  6117 
  6118 		for(TInt i = headerLen; i < frameLength;  )
  6119 		{
  6120 
  6121 			TUint8* memorySeg = NULL;
  6122 			TPtr8 segCopy(memorySeg,increment);
  6123 			HBufC8* segBuff = NULL;
  6124 			segBuff = HBufC8::NewL( increment );
  6125 			#ifdef __MEM_CHECK_
  6126 			PRINT((_L("CVDecTestEngine::CorruptEngine, mem alloc, segBuff") ))
  6127 			#endif
  6128 			iMemAlloc++;
  6129 
  6130 			CleanupStack::PushL( segBuff );
  6131 			segCopy.Set(segBuff->Des());
  6132 
  6133 			if( i < frameLength - increment - 1 )
  6134 			{
  6135 				segCopy = iCodedInBuffer->iData.MidTPtr(i, increment );
  6136 				segCopy.Append('F');
  6137 				i++;
  6138 				PRINT((_L("CVDecTestEngine::CorruptEngin(),[%d]th byte is corrupted"), i ) )
  6139 				tmpPointer.Append( segCopy );
  6140 				i += increment;
  6141 			}
  6142 			else // end of the frame
  6143 			{
  6144 				segCopy = iCodedInBuffer->iData.MidTPtr(i, (frameLength - i) );
  6145 				tmpPointer.Append( segCopy );
  6146 				i = frameLength;
  6147 			}
  6148 
  6149 			CleanupStack::PopAndDestroy( segBuff );
  6150 			iMemDelete++;
  6151 			#ifdef __MEM_CHECK_
  6152 			PRINT((_L("CVDecTestEngine::CorruptEngine, mem del, segBuff") ))
  6153 			#endif
  6154 		}
  6155 		iCodedInBuffer->iData.Set(tmpPointer);
  6156 
  6157 		PRINT((_L("CVDecTestEngine::CorruptEngin(),Filter 1, Out")))
  6158 	}
  6159 	if( iCorruptCounter == iFrameNum )
  6160 	{
  6161 		iFrameCounter = 0;
  6162 		iCorruptCounter = 0;
  6163 	}
  6164 	CleanupStack::PopAndDestroy( tempBuff );
  6165 	iMemDelete++;
  6166 	#ifdef __MEM_CHECK_
  6167 	PRINT((_L("CVDecTestEngine::CorruptEngine, mem del, tempBuff") ))
  6168 	#endif
  6169 	PRINT((_L("CVDecTestEngine::CorruptEngin(), Out")))
  6170 }
  6171 
  6172 
  6173 /* ----------------------------------------------------------------------------
  6174 * Name:       CVDecTestEngine::CorruptEngineL(TVideoInputBuffer*
  6175 aCodedInBuffer)
  6176 * Purpose:    Make the content in the buffer corrupted
  6177 * Note:
  6178 * Parameters: TVideoInputBuffer* aCodedInBuffer
  6179 * Return:     None
  6180 * --------------------------------------------------------------------------*/
  6181 
  6182 void CVDecTestEngine::CorruptEngineL( TVideoInputBuffer* aCodedInBuffer )
  6183 {
  6184 	PRINT((_L("CVDecTestEngine::CorruptEngin(TVideoInputBuffer* aCodedInBuffer), In")))
  6185 	iFrameWriteLength = aCodedInBuffer->iData.Length();
  6186 	if( iInputEnd )
  6187 	{
  6188 		return;
  6189 	}
  6190 	if( iFrameCounter <= iInterval )
  6191 	{
  6192 		if( iFrameCounter < iInterval )
  6193 		{
  6194 			iFrameCounter++;
  6195 			PRINT((_L("CVDecTestEngine::CorruptEngin(TVideoInputBuffer* aCodedInBuffer), Out")))
  6196 			return;
  6197 		}
  6198 		else
  6199 		{
  6200 			iCorruptCounter++;
  6201 		}
  6202 	}
  6203 	else
  6204 	{
  6205 		User::Leave( KErrGeneral);
  6206 	}
  6207 
  6208 	TInt frameLength = aCodedInBuffer->iData.Size();
  6209 	TInt maxLength = aCodedInBuffer->iData.MaxLength();
  6210 
  6211 	TUint8* memoryLocation = NULL;
  6212 	TPtr8 tmpPointer(memoryLocation, frameLength, maxLength );
  6213 	HBufC8* tempBuff = NULL;
  6214 	tempBuff = HBufC8::NewL(iInBuffSize);
  6215 	iMemAlloc++;
  6216 	CleanupStack::PushL( tempBuff );
  6217 	#ifdef __MEM_CHECK_
  6218 	PRINT((_L("CVDecTestEngine::CorruptEngine, mem alloc, tempBuff") ))
  6219 	#endif
  6220 	tmpPointer.Set(tempBuff->Des());
  6221 
  6222 	if( iFilter == 0 )
  6223 	{
  6224 		//Filter 0
  6225 		PRINT((_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),Filter 0, In")))
  6226 		tmpPointer.Set( aCodedInBuffer->iData );
  6227 		PRINT((_L("Length of tmpPointer, %d"), tmpPointer.Length() ) )
  6228 
  6229 		TInt corruptLength = (TInt)( ( frameLength - 8 )* iPercentage / 100 );
  6230 
  6231 		TInt copyLength = frameLength - corruptLength;
  6232 
  6233 		TInt corruptLen = 0;
  6234 
  6235 		for( TInt i = copyLength; i < frameLength; i++ )
  6236 		{
  6237 			// Corrupt the byte by chaning its value instead of setting "zero"
  6238 			if( tmpPointer[i] < 0x05 )
  6239 			{
  6240 				tmpPointer[i] += 0x05;
  6241 			}
  6242 			else
  6243 			{
  6244 				tmpPointer[i] -= 0x05;
  6245 			}
  6246 			corruptLen++;
  6247 		}
  6248 		PRINT((_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),[%d] bytes are corrupted"), corruptLen ) )
  6249 
  6250 		PRINT((_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),Filter 0, Out")))
  6251 	}
  6252 	else if( iFilter == 1)
  6253 	{
  6254 		// Filter 1
  6255 		PRINT((_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),Filter 1, In")))
  6256 		tmpPointer.Set( aCodedInBuffer->iData );
  6257 		PRINT((_L("Length of tmpPointer, %d"), tmpPointer.Length() ) )
  6258 		// To be added here
  6259 		// first 8 bytes of each frame should not be corrupted
  6260 		TInt headerLen = 8;
  6261 
  6262 		TInt increment = (TInt)( ( frameLength - headerLen )/ ( ( frameLength - headerLen) * iPercentage / 100) ) - 1;
  6263 		TInt corruptLen = 0;
  6264 		for(TInt i = headerLen + 1; i < frameLength;  i += increment)
  6265 		{
  6266 			// Corrupt the byte by chaning its value instead of setting "zero"
  6267 			if( tmpPointer[i] < 0x05 )
  6268 			{
  6269 				tmpPointer[i] += 0x05;
  6270 			}
  6271 			else
  6272 			{
  6273 				tmpPointer[i] -= 0x05;
  6274 			}
  6275 			// tmpPointer[i] = 0x00;
  6276 			corruptLen ++;
  6277 		}
  6278 		PRINT((_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),[%d] bytes are corrupted"), corruptLen ) )
  6279 
  6280 		PRINT(_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),Filter 1, Out"))
  6281 	}
  6282 	else if( iFilter == 2)
  6283 	{
  6284 		PRINT(_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),Filter 2, In"))
  6285 		tmpPointer.Set( aCodedInBuffer->iData );
  6286 		PRINT((_L("Length of tmpPointer, %d"), tmpPointer.Length() ) )
  6287 
  6288 		TInt corruptLength = (TInt)( ( frameLength - 8 )* iPercentage / 100 );
  6289 
  6290 		//TInt copyLength = frameLength - corruptLength;
  6291 		iFrameWriteLength -= corruptLength;
  6292 		PRINT((_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),[%d] bytes are removed"), corruptLength ) )
  6293 		// Modify the framesize value in the frame header
  6294 		TUint32 finalSize = (TUint32)( iFrameWriteLength - 8 );
  6295 		for( TInt i = 0; i < 3; i++ )
  6296 		{
  6297 			tmpPointer[i] = (TUint8) ( (  finalSize & ( (0x000000ff)<<(8*i) ) )>> (i*8) );
  6298 		}
  6299 		/* the above assignment equals followings
  6300 		tmpPointer[0] = (TUint8)( finalSize & ~(0xffffff00) );
  6301 		tmpPointer[1] = (TUint8)( ( finalSize & ~(0xffff00ff))>>8 );
  6302 		tmpPointer[2] = (TUint8)( ( finalSize & ~(0xff00ffff))>>16 );
  6303 		*/
  6304 
  6305 		PRINT(_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),Filter 2, Out"))
  6306 	}
  6307 	else      // iFilter == 3
  6308 	{
  6309 		PRINT(_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),Filter 3, In"))
  6310 		tmpPointer.Set( aCodedInBuffer->iData );
  6311 		TInt corruptLength = (TInt)( ( frameLength - 8 )* iPercentage / 100 );
  6312 
  6313 		//TInt copyLength = frameLength - corruptLength;
  6314 		iFrameWriteLength -= corruptLength;
  6315 		// Modify the framesize value in the frame header
  6316 		TUint32 finalSize = (TUint32)( iFrameWriteLength - 8 );
  6317 		for( TInt i = 0; i < 3; i++ )
  6318 		{
  6319 
  6320 			tmpPointer[i] = (TUint8) ( (  finalSize & ( (0x000000ff)<<(8*i) ) )>> (i*8) );
  6321 		}
  6322 		TInt headerLen = 8;
  6323 		// Copy the other bytes for the header
  6324 		for( TInt i = 3; i < headerLen; i++ )
  6325 		{
  6326 
  6327 			tmpPointer[i] = aCodedInBuffer->iData[i];
  6328 		}
  6329 		TInt increment = (TInt)( ( frameLength - headerLen )/ ( ( frameLength - headerLen) * iPercentage / 100) ) - 1;
  6330 		TInt incrementCounter = 0;
  6331 		TInt byteCounter = 0;
  6332 		TInt j = headerLen;
  6333 		for( TInt i = headerLen; i < iFrameWriteLength; i++ )
  6334 		{
  6335 
  6336 			// metadata assignment
  6337 			tmpPointer[i] = aCodedInBuffer->iData[j];
  6338 			if( byteCounter < corruptLength )
  6339 			{
  6340 				incrementCounter++;
  6341 			}
  6342 
  6343 			j++;
  6344 			if( incrementCounter == increment )
  6345 			{
  6346 				j++;
  6347 				incrementCounter = 0;
  6348 				byteCounter++;
  6349 			}
  6350 		}
  6351 
  6352 
  6353 		PRINT(_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),Filter 3, Out"))
  6354 	}
  6355 
  6356 
  6357 
  6358 	aCodedInBuffer->iData.Set(tmpPointer);
  6359 	if( iCorruptCounter == iFrameNum )
  6360 	{
  6361 		iFrameCounter = 0;
  6362 		iCorruptCounter = 0;
  6363 	}
  6364 	CleanupStack::PopAndDestroy( tempBuff );
  6365 	iMemDelete++;
  6366 	#ifdef __MEM_CHECK_
  6367 	PRINT((_L("CVDecTestEngine::CorrupEngineL, mem del, tempBuff") ))
  6368 	#endif
  6369 	PRINT((_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer), Out")))
  6370 }
  6371 
  6372 
  6373 
  6374 /* ----------------------------------------------------------------------------
  6375 * Name:       CVDecTestEngine::CreateCorruptedFile()
  6376 * Purpose:    Make the content in the buffer corrupted and output to a file
  6377 * Note:
  6378 * Parameters:
  6379 * Return:     None
  6380 * --------------------------------------------------------------------------*/
  6381 
  6382 TInt CVDecTestEngine::CreateCorruptedFileL()
  6383 {
  6384 	PRINT((_L("CVDecTestEngine::CreateCorruptedFileL, In")));
  6385 	// Only support VC-1 decoder
  6386 
  6387 	// make new buffer for the data read from the file
  6388 	HBufC8* tmpBuff = NULL;
  6389 
  6390 	TVideoInputBuffer* codedBuffer = new(ELeave) TVideoInputBuffer;
  6391 	CleanupStack::PushL( codedBuffer );
  6392 
  6393 	tmpBuff = HBufC8::NewL(iInBuffSize);
  6394 	CleanupStack::PushL( tmpBuff );
  6395 	codedBuffer->iData.Set(tmpBuff->Des());
  6396 	// read content of the file in the buffer
  6397 	TInt err = 0;
  6398 
  6399 	TInt frameDropNumCounter = 0;
  6400 	while ( !iInputEnd )
  6401 	{
  6402 		// Read the VC1 input video from the very beginning
  6403 		if( iCodecType == EVC1)
  6404 		{
  6405 			err = ReadVC1FrameL( codedBuffer );
  6406 		}
  6407 		else if( iCodecType == EMPEG4 )
  6408 		{
  6409 			err = ReadMPEG4FrameL( codedBuffer );
  6410 		}
  6411 		else
  6412 		{
  6413 
  6414 		}
  6415 
  6416 
  6417 		if( err < 0)
  6418 		{
  6419 			PRINT((_L("CVDecTestEngine::CreateCorruptedFileL, Error reading file") ))
  6420 			return KErrGeneral;
  6421 		}
  6422 		if( err == 0 )
  6423 		{
  6424 			PRINT((_L("CVDecTestEngine::LoadNextFrameL, End of file is found") ))
  6425 			break;
  6426 		}
  6427 		else
  6428 		{
  6429 			// the frame is successfully read and ready to be corrupted
  6430 
  6431 			// make some bytes corrupted
  6432 			if( !iFrameDropMarker )
  6433 			{
  6434 				CorruptEngineL( codedBuffer );
  6435 				PRINT((_L("Corruption is done")));
  6436 			}
  6437 		}
  6438 
  6439 		// Prepare a buffer for copying the bytes from the frame buffer
  6440 		/*
  6441 		TInt copyLen = codedBuffer->iData.Size();
  6442 
  6443 		TUint8* memorySeg = NULL;
  6444 		TPtr8 segCopy(memorySeg,copyLen);
  6445 		HBufC8* segBuff = NULL;
  6446 		segBuff = HBufC8::NewL( copyLen );
  6447 		CleanupStack::PushL( segBuff );
  6448 		segCopy.Set(segBuff->Des());
  6449 		*/
  6450 		if( iFrameDropMarker )
  6451 		{
  6452 			iFrameWriteLength = codedBuffer->iData.Length();
  6453 			// drop the frame specified by the user
  6454 			if( iFrameDropCounter < iFrameDropInterval )
  6455 			{
  6456 				PRINT((_L("CVDecTestEngine::CreateCorruptedFileL,iFrameWriteLength [%d]"), iFrameWriteLength ) )
  6457 				err = iOutCorruptedFile.Write(codedBuffer->iData, iFrameWriteLength );
  6458 				PRINT((_L("Output to the file for frame drop successful")));
  6459 				if ( err!= KErrNone )
  6460 				{
  6461 					PRINT((_L("Output corrupted File write Failed")));
  6462 					iOutCorruptedFile.Close();
  6463 				}
  6464 
  6465 
  6466 
  6467 			}
  6468 			else
  6469 			{
  6470 				frameDropNumCounter++;
  6471 				PRINT((_L("Frame is dropped!")));
  6472 			}
  6473 
  6474 			if( frameDropNumCounter == iFrameDropNum )
  6475 			{
  6476 				iFrameDropCounter = 0;
  6477 				frameDropNumCounter = 0;
  6478 			}
  6479 		}
  6480 		else //write corrupted frame to the file
  6481 		{
  6482 			// Prepare a buffer for copying the bytes from the frame buffer
  6483 			/*         TInt copyLen = codedBuffer->iData.Size();
  6484 
  6485 			TUint8* memorySeg = NULL;
  6486 			TPtr8 segCopy(memorySeg,copyLen);
  6487 			HBufC8* segBuff = NULL;
  6488 			segBuff = HBufC8::NewL( copyLen );
  6489 			CleanupStack::PushL( segBuff );
  6490 			segCopy.Set(segBuff->Des());
  6491 
  6492 			*/
  6493 			PRINT((_L("CVDecTestEngine::CreateCorruptedFileL,iFrameWriteLength [%d]"), iFrameWriteLength ) )
  6494 			err = iOutCorruptedFile.Write(codedBuffer->iData, iFrameWriteLength );
  6495 
  6496 			if ( err!= KErrNone )
  6497 			{
  6498 				PRINT((_L("Output corrupted File write Failed")));
  6499 				iOutCorruptedFile.Close();
  6500 			}
  6501 			PRINT((_L("Output corrupted File is successful")));
  6502 
  6503 		}
  6504 
  6505 	}
  6506 	iOutCorruptedFile.Close();
  6507 	CleanupStack::PopAndDestroy( tmpBuff );
  6508 	CleanupStack::PopAndDestroy( codedBuffer );
  6509 	PRINT((_L("CVDecTestEngine::CreateCorruptedFileL, Out")));
  6510 	return KErrNone;
  6511 }
  6512 
  6513 /* ----------------------------------------------------------------------------
  6514 * Name:       CVDecTestEngine::OpenFileToWriteL()
  6515 * Purpose:    Open output File To Write
  6516 * Note:       Memory buffer output is used
  6517 * Parameters: TFileName& aOutFileName
  6518 * Return:     None
  6519 * --------------------------------------------------------------------------*/
  6520 
  6521 
  6522 void CVDecTestEngine::OpenFileToWriteL(TFileName& aInFileName)
  6523 {
  6524 	PRINT((_L("CVDecTestEngine::OpenFileToWrite, In")));
  6525 	TInt err = KErrNone;
  6526 
  6527 	iOutCorruptedFileName.Copy(aInFileName);
  6528 
  6529 	err = iOutCorruptedFile.Replace(iFs, iOutCorruptedFileName, EFileShareExclusive|EFileWrite);
  6530 
  6531 	iOutCorruptedFileOpen = ETrue;
  6532 
  6533 
  6534 	if ( err!= KErrNone )
  6535 	{
  6536 		PRINT((_L("CVDecTestEngine::OpenFileToWrite, Output corrupted File Replace Failed")));
  6537 		iOutCorruptedFile.Close();
  6538 	}
  6539 
  6540 	AssertTIntEqualL(KErrNone,err);
  6541 	PRINT((_L("CVDecTestEngine::OpenFileToWrite, Out")));
  6542 }
  6543 
  6544 
  6545 /* ----------------------------------------------------------------------------
  6546 * Name:       CVDecTestEngine::ReadVC1FrameL()
  6547 * Purpose:
  6548 * Note:
  6549 * Parameters: None
  6550 * Return:     None
  6551 * --------------------------------------------------------------------------*/
  6552 
  6553 TInt CVDecTestEngine::ReadVC1FrameL(TVideoInputBuffer* aCodedInBuffer)
  6554 {
  6555 	// Note: this function is used as part of corrupt engine to make input
  6556 	// VC1 video corrupted for codec robustness test
  6557 	// Reading VC1 input video from the very beginning of the file
  6558 	PRINT((_L("CVDecTestEngine::ReadVC1FrameL, In")));
  6559 	unsigned int frameDataSize = 4;     //4 Bytes to obain the framesize
  6560 	unsigned int frameSize=0;
  6561 	unsigned int Timestamp;
  6562 	TInt err = 0;
  6563 	TUint8* ptr = new (ELeave) TUint8[frameDataSize];
  6564 	iMemAlloc++;
  6565 	#ifdef __MEM_CHECK_
  6566 	PRINT((_L("CVDecTestEngine::ReadVC1FrameL, mem alloc, ptr") ))
  6567 	#endif
  6568 	TPtr8 frameData(ptr, frameDataSize);
  6569 	if ( (err = iInFile.Read(frameData, frameDataSize)) != KErrNone)
  6570 	{
  6571 		PRINT((_L("CVDecTestEngine::ReadVC1FrameL, Error reading file") ))
  6572 		return err;
  6573 	}
  6574 
  6575 	if (frameData.Length() < 4)
  6576 	{
  6577 		PRINT((_L("CVDecTestEngine::ReadVC1FrameL, File end found") ))
  6578 		aCodedInBuffer->iData.SetLength( 0 );
  6579 		delete ptr;
  6580 		ptr = NULL;
  6581 		iMemDelete++;
  6582 		iInputEnd = ETrue;
  6583 		return KErrNone;
  6584 	}
  6585 
  6586 	PRINT((_L("CVDecTestEngine::ReadVC1FrameL, Reading Item") ))
  6587 	ReadItemLE(ptr, 4, (TUint8 *)&frameSize);
  6588 	PRINT((_L("CVDecTestEngine::ReadVC1FrameL, before AND frameSize: %x"), frameSize ))
  6589 
  6590 	//RCV_V2_FRAMESIZE_FLAGS
  6591 	frameSize = frameSize & ~(0xff000000);
  6592 
  6593 	PRINT((_L("CVDecTestEngine::ReadVC1FrameL, frameSize: %d"), frameSize ))
  6594 
  6595 	//Now obtain the Timestamp of the frame
  6596 	if ( (err = iInFile.Read(frameData, frameDataSize)) != KErrNone)
  6597 	{
  6598 		PRINT((_L("CVDecTestEngine::ReadVC1FrameL, Error reading file %d"), err ))
  6599 		return err;
  6600 	}
  6601 
  6602 	PRINT((_L("CVDecTestEngine::ReadVC1FrameL, Reading Item2") ))
  6603 	ReadItemLE(ptr, 4, (TUint8 *)&Timestamp);
  6604 	PRINT((_L("CVDecTestEngine::ReadVC1FrameL, Timestamp: %d"), Timestamp ))
  6605 	delete ptr;
  6606 	iMemDelete++;
  6607 	#ifdef __MEM_CHECK_
  6608 	PRINT((_L("CVDecTestEngine::ReadVC1FrameL, mem del, ptr") ))
  6609 	#endif
  6610 	if (frameSize != 0)
  6611 	{
  6612 		//Send metadata in the first frame
  6613 		if (iFrame==0)
  6614 		{
  6615 			PRINT((_L("CVDecTestEngine::ReadVC1FrameL, iFrame num == 0, %d"), iFrame ))
  6616 			TInt pos = - ( KVc1HeaderLength + 8 );  // assume the codec is configured
  6617 			err = iInFile.Seek(ESeekCurrent,pos);
  6618 
  6619 			// header length is 36, KVc1HeaderLength = 36
  6620 			PRINT((_L("CVDecTestEngine::ReadVC1FrameL, file header, 36 bytes")))
  6621 			if ( (err = iInFile.Read(aCodedInBuffer->iData, KVc1HeaderLength)) != KErrNone)
  6622 			{
  6623 				PRINT((_L("CVDecTestEngine::ReadVC1FrameL, Error reading file %d"), err ))
  6624 				return err;
  6625 			}
  6626 
  6627 		}
  6628 		else
  6629 		{
  6630 			PRINT((_L("CVDecTestEngine::ReadVC1FrameL, iFrame num = %d"), iFrame ))
  6631 			TInt pos = -8;
  6632 			err = iInFile.Seek(ESeekCurrent, pos);
  6633 			PRINT((_L("CVDecTestEngine::ReadVC1FrameL, read file: %d"), err ))
  6634 			if ( (err = iInFile.Read(aCodedInBuffer->iData, frameSize+8)) != KErrNone)
  6635 			{
  6636 				PRINT((_L("CVDecTestEngine::ReadVC1FrameL, Error reading file %d"), err ))
  6637 				return err;
  6638 			}
  6639 		}
  6640 
  6641 		TInt currentPos = 0;
  6642 		iInFile.Seek(ESeekCurrent, currentPos );
  6643 		PRINT((_L("CVDecTestEngine::ReadVC1FrameL, currentPos %d"), currentPos ))
  6644 		currentPos = 0;
  6645 
  6646 		/*	Not necessary
  6647 		aCodedInBuffer->iSequenceNumber = iFrame;
  6648 		aCodedInBuffer->iOptions = TVideoInputBuffer::EPresentationTimestamp;
  6649 
  6650 		aCodedInBuffer->iPresentationTimestamp = Timestamp;
  6651 		iTimeToPlay = aCodedInBuffer->iPresentationTimestamp ;
  6652 
  6653 
  6654 		aCodedInBuffer->iDecodingTimestamp = Timestamp;
  6655 		iPresentationTimestamp = aCodedInBuffer->iPresentationTimestamp ;
  6656 		*/
  6657 
  6658 
  6659 	}
  6660 
  6661 	iFrame++;
  6662 	iFrameDropCounter++;
  6663 	PRINT(_L("CVDecTestEngine::ReadVC1FrameL.. Out"));
  6664 	return frameSize;
  6665 }
  6666 
  6667 
  6668 
  6669 /* ----------------------------------------------------------------------------
  6670 * Name:       CVDecTestEngine::ReadMPEG4FrameL()
  6671 * Purpose:
  6672 * Note:
  6673 * Parameters: None
  6674 * Return:     None
  6675 * --------------------------------------------------------------------------*/
  6676 
  6677 TInt CVDecTestEngine::ReadMPEG4FrameL(TVideoInputBuffer* aCodedInBuffer)
  6678 {
  6679 	// Note: this function is used as part of corrupt engine to make input
  6680 	// MPEG4 video corrupted for codec robustness test
  6681 	// Reading MPEG4 input video from the very beginning of the file
  6682 	PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, In")));
  6683 	TInt buffLength = iInBuffSize;
  6684 
  6685 	//TUint8* testData =NULL;
  6686 	TInt err = KErrNone;
  6687 
  6688 	if ( aCodedInBuffer->iData.MaxLength() < buffLength )
  6689 	{
  6690 		err = KErrOverflow;
  6691 		PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, Buffer is small, [%d]Byte"),aCodedInBuffer->iData.MaxLength()))
  6692 		return err;
  6693 	}
  6694 
  6695 	aCodedInBuffer->iData.SetLength(0);
  6696 
  6697 	//Buffer is not full,  reset size of buffer
  6698 	if ( aCodedInBuffer->iData.Length() < buffLength)
  6699 	{
  6700 		buffLength = aCodedInBuffer->iData.Length();
  6701 	}
  6702 
  6703 
  6704 
  6705 	TInt pos = 0;
  6706 	TBool found = EFalse;
  6707 	TBool firstStartCode = EFalse;
  6708 	//TUint8 byte = 0;
  6709 	TInt currentPos = 0;
  6710 	iInFile.Seek(ESeekCurrent, currentPos );
  6711 	if( currentPos != 0 && currentPos == iCurrentFilePos )
  6712 	{
  6713 		iInputEnd = ETrue;
  6714 	}
  6715 	else
  6716 	{
  6717 		iCurrentFilePos = currentPos;
  6718 	}
  6719 	PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, currentPos %d"), currentPos ))
  6720 	while (!iInputEnd && !found)
  6721 	{
  6722 		TInt zeroCounter = 0;
  6723 		err = iInFile.Read(aCodedInBuffer->iData, 1 ); // read one byte
  6724 		if( aCodedInBuffer->iData.Length() == 0 )
  6725 		{
  6726 			pos++;
  6727 			iInputEnd = ETrue;
  6728 			break;
  6729 		}
  6730 
  6731 		while( aCodedInBuffer->iData[0] == 0x00 && !iInputEnd )
  6732 		{
  6733 			zeroCounter++;
  6734 			pos++;
  6735 			err = iInFile.Read(aCodedInBuffer->iData, 1 ); // read one byte
  6736 		}
  6737 		pos++;
  6738 		if ((zeroCounter >= 2) && (aCodedInBuffer->iData[0] == 0x01))
  6739 		{
  6740 			//byte = ReadByteFromFile();
  6741 			err = iInFile.Read(aCodedInBuffer->iData, 1 ); // read one byte
  6742 			//PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, iData %d, f2"), aCodedInBuffer->iData[0] ))
  6743 			pos++;
  6744 			//if (byte == 0xB6 && !firstStartCode)
  6745 			if( aCodedInBuffer->iData[0] == 0xB6 && !firstStartCode )
  6746 			{
  6747 				firstStartCode = ETrue;
  6748 			}
  6749 			//else if (byte != 0xB1 && firstStartCode)
  6750 			else if( aCodedInBuffer->iData[0]!= 0xB1 && firstStartCode )
  6751 			{
  6752 				PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, end of mpeg-4 picture found [%d]"), pos-4))
  6753 				found = ETrue;
  6754 			}
  6755 		}
  6756 	}
  6757 	PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, pos (read length), %d"), pos))
  6758 	TInt backward = 0 - pos;
  6759 	err = iInFile.Seek(ESeekCurrent, backward );// go back
  6760 
  6761 	if( err != KErrNone)
  6762 	{
  6763 		PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, Error seeking file %d"), err ))
  6764 		return err;
  6765 	}
  6766 
  6767 	if (iInputEnd)
  6768 	{
  6769 		PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, inputEndFound, %d"), pos))
  6770 		pos--;
  6771 	}
  6772 	else
  6773 	{
  6774 		pos -= 4;
  6775 	}
  6776 
  6777 
  6778 	currentPos = 0;
  6779 	err = iInFile.Seek( ESeekCurrent, currentPos);
  6780 	PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, position goes back to the beginning, %d"), currentPos))
  6781 	if ( (err = iInFile.Read(aCodedInBuffer->iData, pos )) != KErrNone)
  6782 	{
  6783 		PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, Error reading file %d"), err ))
  6784 		return err;
  6785 	}
  6786 	if( aCodedInBuffer->iData.Length() < 4 )
  6787 	{
  6788 		iInputEnd = ETrue;
  6789 	}
  6790 	iFrameDropCounter++;
  6791 	iFrame++;
  6792 	PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, iFrameDropCounter, %d"), iFrameDropCounter))
  6793 	PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, Out")));
  6794 	return pos;
  6795 }
  6796 
  6797 /* ----------------------------------------------------------------------------
  6798 * Name:       CVDecTestEngine::SetFrameDrop()
  6799 * Purpose:
  6800 * Note:
  6801 * Parameters: TInt aFrameInterval, TInt aFrameNum, TBool aFrameDropMarker
  6802 * Return:     None
  6803 * --------------------------------------------------------------------------*/
  6804 
  6805 void CVDecTestEngine::SetFrameDrop(TInt aFrameInterval, TInt aFrameNum, TBool aFrameDropMarker )
  6806 {
  6807 	PRINT(_L("CVDecTestEngine::SetFrameDrop, In"));
  6808 
  6809 
  6810 	iFrameDropInterval = aFrameInterval;
  6811 	iFrameDropNum = aFrameNum;
  6812 	iFrameDropMarker = aFrameDropMarker;
  6813 
  6814 
  6815 	PRINT(_L("CVDecTestEngine::SetFrameDrop, Out"));
  6816 }
  6817 
  6818 /* ----------------------------------------------------------------------------
  6819 * Name:       CVDecTestEngine::SetFLVPassword()
  6820 * Purpose:
  6821 * Note:
  6822 * Parameters: TDesC8& aPassword
  6823 * Return:     None
  6824 * --------------------------------------------------------------------------*/
  6825 void CVDecTestEngine::SetFLVPassword(TDesC8& aPassword)
  6826 {
  6827 	PRINT(_L("CVDecTestEngine::SetFLVPassword, In"));
  6828 
  6829 	_LIT8(KNullTerminate, "\0");
  6830 	iSetPassword = ETrue;
  6831 	iPasswordForFLV.Copy( aPassword);
  6832 	iPasswordForFLV.Append( KNullTerminate );
  6833 	TBuf16<128> passwordPrint;
  6834 	passwordPrint.Copy( iPasswordForFLV );
  6835 
  6836 	PRINT((_L("CVDecTestEngine::SetFLVPassword, iPasswordForFLV [%S]"), &passwordPrint))
  6837 	PRINT(_L("CVDecTestEngine::SetFLVPassword, Out"));
  6838 
  6839 }
  6840 
  6841 /* ----------------------------------------------------------------------------
  6842 * Name:       CVDecTestEngine::EnablingInstantFpsL()
  6843 * Purpose:
  6844 * Note:
  6845 * Parameters: TFileName& aOutFileName
  6846 * Return:     None
  6847 * --------------------------------------------------------------------------*/
  6848 void CVDecTestEngine::EnableInstantFpsL(TFileName& aOutFileName)
  6849 {
  6850 	TInt err = KErrNone;
  6851 	if (!iFrameMeasurement)
  6852 	{
  6853 
  6854 		PRINT((_L("CVDecTestEngine::EnableInstantFpsL(), Frame measurement is not enabled")))
  6855 
  6856 		User::Leave(KErrGeneral);
  6857 	}
  6858 
  6859 	err = iFpsFile.Replace(iFs, aOutFileName, EFileShareExclusive|EFileWrite);
  6860 
  6861 	if ( err  != KErrNone)
  6862 	{
  6863 		PRINT((_L("CVDecTestEngine::EnableInstantFpsL, Output File open Failed")));
  6864 		User::Leave(err);
  6865 	}
  6866 
  6867 	iInstantFpsEnabled = ETrue;
  6868 }
  6869 
  6870 /* ----------------------------------------------------------------------------
  6871 * Name:       CVDecTestEngine::SetSecondScreenAccess
  6872 * Purpose:    Set second screen
  6873 * Note:
  6874 * Parameters: TBool aStatus
  6875 * Return:     None
  6876 * --------------------------------------------------------------------------*/
  6877 void CVDecTestEngine::SetSecondScreenAccess(TBool aStatus)
  6878 {
  6879 	iUseSecondScreen = aStatus;
  6880 }
  6881 //  End	of File