os/mm/mmapitest/devvideohaitest/src/H264DecTestEngine.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmapitest/devvideohaitest/src/H264DecTestEngine.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,6881 @@
     1.4 +/*
     1.5 +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +// INCLUDE FILES
    1.24 +#include "H264DecTestEngine.h"
    1.25 +#include "T_DevVideoConstants.h"
    1.26 +
    1.27 +#ifdef __CI_HEADERS__
    1.28 +#include <buffermanagementci.h>  // Custom interface buffre management
    1.29 +
    1.30 +#endif
    1.31 +
    1.32 +
    1.33 +#ifdef __SECUREOUTPUTCI__
    1.34 +#include <secureoutputci.h>
    1.35 +#endif
    1.36 +
    1.37 +#include <Devvideoplay.h>
    1.38 +#include <Devvideobase.h>
    1.39 +#include <Devvideoconstants.h>
    1.40 +#include <hal.h>
    1.41 +#include <hal_data.h>
    1.42 +//#define __MEM_CHECK_
    1.43 +
    1.44 +
    1.45 +// Ecom
    1.46 +#include <ecom.h>
    1.47 +
    1.48 +
    1.49 +/* ----------------------------------------------------------------------------
    1.50 +* Name:       CVDecTestEngine::~CVDecTestEngine()
    1.51 +* Purpose:    Deconstructor
    1.52 +* Parameters: None
    1.53 +* Return:     None
    1.54 +* --------------------------------------------------------------------------*/
    1.55 +
    1.56 +CVDecTestEngine::~CVDecTestEngine ()
    1.57 +{
    1.58 +	delete iDecTestAO;
    1.59 +	delete iClock;
    1.60 +}
    1.61 +
    1.62 +
    1.63 +/* ----------------------------------------------------------------------------
    1.64 +* Name:       CVDecTestEngine:NewL()
    1.65 +* Purpose:    Create instance of test engine
    1.66 +* Parameters: MVDecEngineObserver& aTestClass
    1.67 +* Return:     CVDecTestEngine*
    1.68 +* --------------------------------------------------------------------------*/
    1.69 +
    1.70 +CVDecTestEngine* CVDecTestEngine::NewL(MVDecEngineObserver& aTestClass)
    1.71 +{
    1.72 +	CVDecTestEngine* self = new(ELeave) CVDecTestEngine;
    1.73 +
    1.74 +	CleanupStack::PushL( self );
    1.75 +	self->ConstructL(aTestClass);
    1.76 +	CleanupStack::Pop();
    1.77 +
    1.78 +	return self;
    1.79 +}
    1.80 +
    1.81 +
    1.82 +/* ----------------------------------------------------------------------------
    1.83 +* Name:       CVDecTestEngine::ConstructL()
    1.84 +* Purpose:    Symbian second phase constructor, which may leave
    1.85 +* Parameters: MVDecEngineObserver& aTestClass
    1.86 +* Return:     None
    1.87 +* --------------------------------------------------------------------------*/
    1.88 +
    1.89 +
    1.90 +void CVDecTestEngine::ConstructL(MVDecEngineObserver& aTestClass)
    1.91 +{
    1.92 +	iState = EStateNone;
    1.93 +	iTestClass = &aTestClass;
    1.94 +	iScreenDevice = NULL;
    1.95 +
    1.96 +	//Create Active object
    1.97 +	iDecTestAO = new(ELeave) CVDecTestAO(this);
    1.98 +
    1.99 +	//clock source from system clock
   1.100 +	iClock = CSystemClockSource::NewL();
   1.101 +}
   1.102 +
   1.103 +
   1.104 +/* ----------------------------------------------------------------------------
   1.105 +* Name:       CVDecTestEngine::AssertTIntEqualL()
   1.106 +* Purpose:
   1.107 +*
   1.108 +* Parameters: TInt aExpected, TInt aActual
   1.109 +* Return:     None
   1.110 +* --------------------------------------------------------------------------*/
   1.111 +
   1.112 +void CVDecTestEngine::AssertTIntEqualL(TInt aExpected, TInt aActual)
   1.113 +{
   1.114 +	if ( aExpected != aActual )
   1.115 +	{
   1.116 +		User::Leave(aActual);
   1.117 +	}
   1.118 +}
   1.119 +
   1.120 +/* ----------------------------------------------------------------------------
   1.121 +* Name:       CVDecTestEngine::SetUp()
   1.122 +* Purpose:    Create DevVideoPlay, Initilize Engine paramters
   1.123 +* Parameters: TSize aSize, TBool aScreenAccess, TBool aSynchronized, TBool aCIBuffMgmt
   1.124 +* Return:     None
   1.125 +* --------------------------------------------------------------------------*/
   1.126 +
   1.127 +void CVDecTestEngine::SetUpL(TSize aSize, TBool aScreenAccess, TBool aCIBuffMgmt)
   1.128 +{
   1.129 +
   1.130 +	iMemAlloc = 0;
   1.131 +	iMemDelete = 0;
   1.132 +	//Create DevVideoPlay
   1.133 +	iDevvp = CMMFDevVideoPlay::NewL(*this);
   1.134 +	PRINT((_L("CVDecTestEngine::SetUpL, DevVideo Created")))
   1.135 +	#ifdef __MEM_CHECK_
   1.136 +	PRINT((_L("CVDecTestEngine::SetUpL, mem alloc, iDevvp") ))
   1.137 +	#endif
   1.138 +	iMemAlloc++;
   1.139 +	iState = ECreated;
   1.140 +
   1.141 +	// Initilize Engine parameters
   1.142 +	iError = KErrNone;
   1.143 +	iDecHWDevId = 0;
   1.144 +	iPostProcId = 0;
   1.145 +	iInBuffSize = 0;
   1.146 +	iRawDataArea = NULL;
   1.147 +	iCodecType = ENoCodec;
   1.148 +	iInputEnd = EFalse;
   1.149 +	iFrameMatch = EFalse;
   1.150 +	iFrameJump = 0;
   1.151 +	iFrameJumpCounter = 0;
   1.152 +	iCorruptMarker = EFalse;
   1.153 +	iOutCorruptedFileOpen = EFalse;
   1.154 +	iFrameCounter = 0;
   1.155 +	iCorruptCounter = 0;
   1.156 +	iFlvCounter = 0;
   1.157 +	iFrameDropCounter = 0;
   1.158 +	iFrameDropInterval = 0;
   1.159 +	iFrameDropNum = 0;
   1.160 +	iFrameDropMarker = EFalse;
   1.161 +	iCurrentFilePos = 0;
   1.162 +	iFrameDropNumCounter = 0;
   1.163 +	iSetPassword = EFalse;
   1.164 +	iUseSecondScreen = EFalse;
   1.165 +
   1.166 +
   1.167 +	#ifdef __CI_HEADERS__
   1.168 +	iCIBuffMgmtOn = aCIBuffMgmt;
   1.169 +	#endif
   1.170 +
   1.171 +	iDirectScreenAccess = aScreenAccess;
   1.172 +	iSynchronized = EFalse;
   1.173 +	iLandscapeMode =EFalse;
   1.174 +
   1.175 +	PRINT((_L("CVDecTestEngine::SetUpL, reserving data chunk")));
   1.176 +
   1.177 +
   1.178 +	if (aSize.iWidth > 720 && aSize.iWidth > 576 )
   1.179 +	{
   1.180 +		iDataChunkSize = KMP4MaxCodedSize720P*4;
   1.181 +		iDataThreshold = KMP4MaxCodedSize720P;
   1.182 +	}
   1.183 +	else if (aSize.iWidth > 640 && aSize.iWidth > 480 )
   1.184 +	{
   1.185 +		iDataChunkSize = KMP4MaxCodedSizePAL*4;
   1.186 +		iDataThreshold = KMP4MaxCodedSizePAL;
   1.187 +	}
   1.188 +	else if (aSize.iWidth > 352 && aSize.iWidth > 288 )
   1.189 +	{
   1.190 +		iDataChunkSize = KMP4MaxCodedSizeVGA*4;
   1.191 +		iDataThreshold = KMP4MaxCodedSizeVGA;
   1.192 +	}
   1.193 +	else if (aSize.iWidth <= 352 && aSize.iWidth > 176)
   1.194 +	{
   1.195 +		iDataChunkSize = KMP4MaxCodedSizeCIF*4;
   1.196 +		iDataThreshold = KMP4MaxCodedSizeCIF;
   1.197 +	}
   1.198 +	else
   1.199 +	{
   1.200 +		iDataChunkSize = KMP4MaxCodedSizeQCIF*4;
   1.201 +		iDataThreshold = KMP4MaxCodedSizeQCIF;
   1.202 +	}
   1.203 +	PRINT((_L("CVDecTestEngine::SetUpL, Data chunk size is [%d]"), iDataChunkSize));
   1.204 +	PRINT((_L("CVDecTestEngine::SetUpL, Data threshold [%d]"), iDataThreshold));
   1.205 +	iDataChunk = new (ELeave) TUint8[iDataChunkSize];
   1.206 +	iMemAlloc++;
   1.207 +	#ifdef __MEM_CHECK_
   1.208 +	PRINT((_L("CVDecTestEngine::SetUpL, mem alloc, iDataChunk") ));
   1.209 +	#endif
   1.210 +	iReadDataChunk = iDataChunk;
   1.211 +	iWriteDataChunk = iDataChunk;
   1.212 +
   1.213 +
   1.214 +	iPictureSize.SetSize(aSize.iWidth,aSize.iHeight);
   1.215 +	TRect rect(iPictureSize);
   1.216 +	iDispRect = rect;
   1.217 +	iFrameMeasurement = EFalse;
   1.218 +	iDsaStarted = EFalse;
   1.219 +
   1.220 +	if ( aScreenAccess )
   1.221 +	{
   1.222 +		User::LeaveIfError( FbsStartup() );
   1.223 +		PRINT((_L("CVDecTestEngine::SetUpL, Fbs server started:")))
   1.224 +	}
   1.225 +
   1.226 +	//Open File session
   1.227 +	TInt err;
   1.228 +
   1.229 +	if ( (err = iFs.Connect()) != KErrNone )
   1.230 +	{
   1.231 +		PRINT((_L("CVDecTestEngine::SetUpL, Open File server session fail ")))
   1.232 +		User::Leave(err);
   1.233 +	}
   1.234 +}
   1.235 +
   1.236 +/* ----------------------------------------------------------------------------
   1.237 +* Name:       CVDecTestEngine::EnableFrameMeasurementTest
   1.238 +* Purpose:    Enable Perforamce test flag
   1.239 +* Note
   1.240 +* Parameters: TBool a Enable
   1.241 +* Return:     None
   1.242 +* --------------------------------------------------------------------------*/
   1.243 +
   1.244 +void CVDecTestEngine::EnableFrameMeasurementTest(TBool aEnable)
   1.245 +{
   1.246 +	iFrameMeasurement = aEnable;
   1.247 +}
   1.248 +
   1.249 +/* ----------------------------------------------------------------------------
   1.250 +* Name:       CVDecTestEngine::SetInputBufferSize
   1.251 +* Purpose:
   1.252 +* Note
   1.253 +* Parameters: TBool a Enable
   1.254 +* Return:     None
   1.255 +* --------------------------------------------------------------------------*/
   1.256 +
   1.257 +void CVDecTestEngine::SetInputBufferSize(TInt aSize)
   1.258 +{
   1.259 +	iInBuffSize = aSize;
   1.260 +	if ( iCIBuffMgmtOn )  //Custom interfarce Buffer management is used
   1.261 +	{
   1.262 +		PRINT((_L("CVDecTestEngine::SetInputBufferSize, CI Buffer management")))
   1.263 +		#ifdef __CI_HEADERS__
   1.264 +		iCIBuffMgmt = (MMmfVideoBufferManagement*)iDevvp->CustomInterface(iPostProcId, KMmfVideoBuffermanagementUid);
   1.265 +		iCIBuffMgmt->MmvbmSetObserver(this);
   1.266 +		iCIBuffMgmt->MmvbmEnable(ETrue);
   1.267 +
   1.268 +		MMmfVideoBufferManagement::TBufferOptions options;
   1.269 +		options.iNumInputBuffers = KNumOfInputBuffers;
   1.270 +		options.iBufferSize = iPictureSize;
   1.271 +
   1.272 +		iCIBuffMgmt->MmvbmSetBufferOptionsL(options);
   1.273 +
   1.274 +		PRINT((_L("CVDecTestEngine::SetInputBufferSize, CI Buffer management Set, Buff size:[%d],[%d]"),iPictureSize.iWidth,iPictureSize.iHeight))
   1.275 +		#endif
   1.276 +	}
   1.277 +
   1.278 +	else  //Use default Devvideo API for buffer management
   1.279 +	{
   1.280 +
   1.281 +		iRawInBuffer = new(ELeave) TVideoPicture;
   1.282 +		iMemAlloc++;
   1.283 +		#ifdef __MEM_CHECK_
   1.284 +		PRINT((_L("CVDecTestEngine::SetInputBufferSize, mem alloc, iRawInBuffer") ));
   1.285 +		#endif
   1.286 +		TUint8* ptr = new (ELeave) TUint8[iInBuffSize];
   1.287 +		iMemAlloc++;
   1.288 +		#ifdef __MEM_CHECK_
   1.289 +		PRINT((_L("CVDecTestEngine::SetInputBufferSize, mem alloc, ptr") ));
   1.290 +		#endif
   1.291 +		TPtr8*  temp = new (ELeave) TPtr8(ptr, 0, iInBuffSize);
   1.292 +		iMemAlloc++;
   1.293 +		#ifdef __MEM_CHECK_
   1.294 +		PRINT((_L("CVDecTestEngine::SetInputBufferSize, mem alloc, temp") ));
   1.295 +		#endif
   1.296 +		iRawInBuffer->iData.iRawData = temp;
   1.297 +
   1.298 +		iRawInBuffer->iData.iDataSize.SetSize(iPictureSize.iWidth,iPictureSize.iHeight); //set picture size
   1.299 +
   1.300 +		iRawInBuffer->iOptions = 0;
   1.301 +		iRawInBuffer->iTimestamp = 0;
   1.302 +		delete ptr;
   1.303 +		iMemDelete++;
   1.304 +		delete temp;
   1.305 +		iMemDelete++;
   1.306 +		#ifdef __MEM_CHECK_
   1.307 +		PRINT((_L("CVDecTestEngine::SetInputBufferSize, mem del, ptr & temp") ));
   1.308 +		#endif
   1.309 +		PRINT((_L("CVDecTestEngine::SetInputBufferSize, Buffer created: Size[%d]"),iInBuffSize))
   1.310 +	}
   1.311 +}
   1.312 +
   1.313 +
   1.314 +/* ----------------------------------------------------------------------------
   1.315 +* Name:       CVDecTestEngine::GetHeaderInformationL()
   1.316 +* Purpose:    Ritrieve header  Information
   1.317 +* Parameters: TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aDataUnitEncapsulation
   1.318 +* Return:     None
   1.319 +*---------------------------------------------------------------------------*/
   1.320 +
   1.321 +void CVDecTestEngine::GetHeaderInformationL(TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aDataUnitEncapsulation)
   1.322 +{
   1.323 +	TInt err = KErrNone;
   1.324 +	TVideoPictureHeader* headerInfo = NULL;
   1.325 +	HBufC8* tempBuff = NULL;
   1.326 +
   1.327 +	//Read Picture header : Size is not known
   1.328 +	TVideoInputBuffer* codedBuffer = new(ELeave) TVideoInputBuffer;
   1.329 +	iMemAlloc++;
   1.330 +	CleanupStack::PushL( codedBuffer );
   1.331 +	#ifdef __MEM_CHECK_
   1.332 +	PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem alloc, codedBuffer") ))
   1.333 +	#endif
   1.334 +	iInBuffSize = KMaxCodedSize;
   1.335 +	err = KErrOverflow;
   1.336 +
   1.337 +	while ( (err == KErrOverflow) && (iInBuffSize <= KMaxCodedSize) )
   1.338 +	{
   1.339 +		tempBuff = HBufC8::NewL(iInBuffSize);
   1.340 +		iMemAlloc++;
   1.341 +		CleanupStack::PushL( tempBuff );
   1.342 +		#ifdef __MEM_CHECK_
   1.343 +		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem alloc, codedBuffer") ))
   1.344 +		#endif
   1.345 +		codedBuffer->iData.Set(tempBuff->Des());
   1.346 +		if ( iFrameSizeList.Count() > 0 )
   1.347 +		{
   1.348 +			err = ReadOneCodedPicture(codedBuffer, iFrameSizeList[0] );
   1.349 +		}
   1.350 +		else
   1.351 +		{
   1.352 +			err = ReadOneCodedPicture(codedBuffer);
   1.353 +		}
   1.354 +
   1.355 +		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, return err [%d]"),err))
   1.356 +		TInt pos =0;
   1.357 +		if ( iInFile.Seek(ESeekStart,pos) )
   1.358 +		{
   1.359 +			err = KErrGeneral;
   1.360 +			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, err = KErrGeneral")))
   1.361 +		}
   1.362 +
   1.363 +		if ( iInputEnd )
   1.364 +		{
   1.365 +			err = KErrNotFound;
   1.366 +			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, err = KErrNotFound")))
   1.367 +		}
   1.368 +
   1.369 +		if ( err < 0 )
   1.370 +		{
   1.371 +			CleanupStack::PopAndDestroy(tempBuff);
   1.372 +			iMemDelete++;
   1.373 +			#ifdef __MEM_CHECK_
   1.374 +			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem del, tempBuff") ))
   1.375 +			#endif
   1.376 +			iInBuffSize = 4*iInBuffSize;
   1.377 +		}
   1.378 +	}
   1.379 +
   1.380 +	// Reitrieve header information from bitstream
   1.381 +	if ( err < 0 )
   1.382 +	{
   1.383 +		CleanupStack::PopAndDestroy(codedBuffer);
   1.384 +		iMemDelete++;
   1.385 +		#ifdef __MEM_CHECK_
   1.386 +		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem del, codedBuffer") ))
   1.387 +		#endif
   1.388 +		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Reading input data fail")))
   1.389 +	}
   1.390 +	else
   1.391 +	{
   1.392 +		err = KErrNone;
   1.393 +		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, call adaptation layer")))
   1.394 +		headerInfo = iDevvp->GetHeaderInformationL(aDataUnitType,aDataUnitEncapsulation,codedBuffer);
   1.395 +
   1.396 +		CleanupStack::PopAndDestroy(tempBuff);
   1.397 +		iMemDelete++;
   1.398 +		CleanupStack::PopAndDestroy(codedBuffer);
   1.399 +		iMemDelete++;
   1.400 +		#ifdef __MEM_CHECK_
   1.401 +		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem del, tempBuff & codedBuffer") ))
   1.402 +		#endif
   1.403 +		//Check Header info
   1.404 +		if ( !err && headerInfo )
   1.405 +		{
   1.406 +			//Size in Memory
   1.407 +			iPictureSize = headerInfo->iDisplayedRect.Size();
   1.408 +			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Picture Size :width[%d], height[%d]"),iPictureSize.iWidth,iPictureSize.iHeight))
   1.409 +
   1.410 +			// Display rect
   1.411 +			iDispRect = headerInfo->iDisplayedRect;
   1.412 +			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Displayed image portion: Width[%d] to Height[%d]"),headerInfo->iDisplayedRect.Width(),headerInfo->iDisplayedRect.Height()))
   1.413 +
   1.414 +			//return headerInfo
   1.415 +			iDevvp->ReturnHeader(headerInfo);
   1.416 +
   1.417 +		}
   1.418 +		else  //temp modify because MP4HwDevice of Emuzed returns null information in 1st release
   1.419 +		{
   1.420 +			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Get header info fail")))
   1.421 +			err = KErrGeneral;
   1.422 +		}
   1.423 +	}
   1.424 +
   1.425 +	AssertTIntEqualL(KErrNone, err);
   1.426 +
   1.427 +}
   1.428 +
   1.429 +
   1.430 +/* ----------------------------------------------------------------------------
   1.431 +* Name:       CVDecTestEngine::GetHeaderInformationL()
   1.432 +* Purpose:    Retrieve header Information
   1.433 +* Parameters: None
   1.434 +* Return:     None
   1.435 +*---------------------------------------------------------------------------*/
   1.436 +
   1.437 +void CVDecTestEngine::GetHeaderInformationL()
   1.438 +{
   1.439 +	PRINT((_L("CVDecTestEngine::GetHeaderInformationL, In")))
   1.440 +	TInt err = KErrNone;
   1.441 +	TVideoPictureHeader* headerInfo = NULL;
   1.442 +	HBufC8* tempBuff = NULL;
   1.443 +
   1.444 +	//Read Picture header : Size is not known
   1.445 +	TVideoInputBuffer* codedBuffer = new(ELeave) TVideoInputBuffer;
   1.446 +	iMemAlloc++;
   1.447 +	CleanupStack::PushL( codedBuffer );
   1.448 +	#ifdef __MEM_CHECK_
   1.449 +	PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem alloc, codedBuffer") ))
   1.450 +	#endif
   1.451 +	iInBuffSize = KMaxCodedSize;
   1.452 +	err = KErrOverflow;
   1.453 +
   1.454 +	while ( (err == KErrOverflow) && (iInBuffSize <= KMaxCodedSize) )
   1.455 +	{
   1.456 +		tempBuff = HBufC8::NewL(iInBuffSize);
   1.457 +		iMemAlloc++;
   1.458 +		CleanupStack::PushL( tempBuff );
   1.459 +		#ifdef __MEM_CHECK_
   1.460 +		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem alloc, tempBuff") ))
   1.461 +		#endif
   1.462 +		codedBuffer->iData.Set(tempBuff->Des());
   1.463 +
   1.464 +		if ( iFrameSizeList.Count() > 0 )
   1.465 +		{
   1.466 +			err = ReadOneCodedPicture(codedBuffer, iFrameSizeList[0] );
   1.467 +		}
   1.468 +		else
   1.469 +		{
   1.470 +			err = ReadOneCodedPicture(codedBuffer);
   1.471 +		}
   1.472 +
   1.473 +
   1.474 +		TInt pos =0;
   1.475 +		if ( iInFile.Seek(ESeekStart,pos) )
   1.476 +		{
   1.477 +			err = KErrGeneral;
   1.478 +		}
   1.479 +
   1.480 +		if ( iInputEnd )
   1.481 +		{
   1.482 +			err = KErrNotFound;
   1.483 +		}
   1.484 +
   1.485 +		if ( err < 0 )
   1.486 +		{
   1.487 +			CleanupStack::PopAndDestroy(tempBuff);
   1.488 +			iMemDelete++;
   1.489 +			#ifdef __MEM_CHECK_
   1.490 +			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem del, tempBuff") ))
   1.491 +			#endif
   1.492 +			iInBuffSize = 4*iInBuffSize;
   1.493 +		}
   1.494 +	}
   1.495 +
   1.496 +
   1.497 +	// Reitrieve header information from bitstream
   1.498 +	if ( err  < 0 )
   1.499 +	{
   1.500 +		CleanupStack::PopAndDestroy(codedBuffer);
   1.501 +		iMemDelete++;
   1.502 +		#ifdef __MEM_CHECK_
   1.503 +		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem del, codedBuffer") ))
   1.504 +		#endif
   1.505 +		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Reading input data fail")))
   1.506 +	}
   1.507 +	else
   1.508 +	{
   1.509 +		err = KErrNone;
   1.510 +
   1.511 +		headerInfo = iDevvp->GetHeaderInformationL(EDuCodedPicture,EDuElementaryStream,codedBuffer);
   1.512 +
   1.513 +		CleanupStack::PopAndDestroy(tempBuff);
   1.514 +		CleanupStack::PopAndDestroy(codedBuffer);
   1.515 +		iMemDelete++;
   1.516 +		iMemDelete++;
   1.517 +		#ifdef __MEM_CHECK_
   1.518 +		PRINT((_L("CVDecTestEngine::GetHeaderInformationL, mem del, tempBuff & codedBuffer") ))
   1.519 +		#endif
   1.520 +
   1.521 +		//Check Header info
   1.522 +		if ( headerInfo )
   1.523 +		{
   1.524 +			//Size in Memory
   1.525 +			iPictureSize = headerInfo->iDisplayedRect.Size();
   1.526 +			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Picture Size :width[%d], height[%d]"),iPictureSize.iWidth,iPictureSize.iHeight))
   1.527 +
   1.528 +			// Display rect
   1.529 +			iDispRect = headerInfo->iDisplayedRect;
   1.530 +			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Displayed image portion: Width[%d] to Height[%d]"),headerInfo->iDisplayedRect.Width(),headerInfo->iDisplayedRect.Height()))
   1.531 +
   1.532 +			iDevvp->ReturnHeader(headerInfo);
   1.533 +
   1.534 +		}
   1.535 +		else
   1.536 +		{
   1.537 +			PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Get header info fail")))
   1.538 +			err = KErrGeneral;
   1.539 +		}
   1.540 +
   1.541 +	}
   1.542 +
   1.543 +	// Set size of decoder input buffer
   1.544 +	if ( iCodecType == EH263 )
   1.545 +	{
   1.546 +		if ( (iPictureSize.iWidth <= 176 ) && (iPictureSize.iHeight <= 144) )
   1.547 +		{
   1.548 +			iInBuffSize = KH263MaxCodedSizeQCIF;
   1.549 +		}
   1.550 +		else
   1.551 +		{
   1.552 +			iInBuffSize = KH263MaxCodedSizeCIF;
   1.553 +		}
   1.554 +	}
   1.555 +	else //Mpeg4
   1.556 +	{
   1.557 +		if ( (iPictureSize.iWidth <= 176 ) && (iPictureSize.iHeight <= 144) )
   1.558 +		{
   1.559 +			iInBuffSize = KMP4MaxCodedSizeQCIF;
   1.560 +		}
   1.561 +		else if ( (iPictureSize.iWidth <= 352 ) && (iPictureSize.iHeight <= 288) )
   1.562 +		{
   1.563 +			iInBuffSize = KMP4MaxCodedSizeCIF;
   1.564 +		}
   1.565 +
   1.566 +		else
   1.567 +		{
   1.568 +			iInBuffSize = KMP4MaxCodedSizeVGA;
   1.569 +		}
   1.570 +
   1.571 +	}
   1.572 +
   1.573 +	AssertTIntEqualL(KErrNone, err);
   1.574 +	PRINT((_L("CVDecTestEngine::GetHeaderInformationL, Out")))
   1.575 +}
   1.576 +
   1.577 +/* ----------------------------------------------------------------------------
   1.578 +* Name:       CVDecTestEngine::SetCodecType
   1.579 +* Purpose:    Set Cotec type
   1.580 +* Parameters: TVideoCodec aCodec
   1.581 +*
   1.582 +* Return:     None
   1.583 +* --------------------------------------------------------------------------*/
   1.584 +
   1.585 +void CVDecTestEngine::SetCodecType(TVideoCodec aCodec)
   1.586 +{
   1.587 +	iCodecType = aCodec;
   1.588 +}
   1.589 +
   1.590 +/* ----------------------------------------------------------------------------
   1.591 +* Name:       CVDecTestEngine::GetBitstreamCountersL()
   1.592 +* Purpose:
   1.593 +* Parameters:
   1.594 +*
   1.595 +* Return:     None
   1.596 +* --------------------------------------------------------------------------*/
   1.597 +
   1.598 +void CVDecTestEngine::GetBitstreamCountersL()
   1.599 +{
   1.600 +	PRINT((_L("CVDecTestEngine::GetBitstreamCountersL In")))
   1.601 +
   1.602 +	CMMFDevVideoPlay::TBitstreamCounters lCounters;
   1.603 +
   1.604 +	iDevvp->GetBitstreamCounters(lCounters);
   1.605 +
   1.606 +	PRINT((_L("CVDecTestEngine::GetBitstreamCountersL, Lost Packets = %d"),lCounters.iLostPackets))
   1.607 +	PRINT((_L("CVDecTestEngine::GetBitstreamCountersL, Total Packets = %d"), lCounters.iTotalPackets))
   1.608 +
   1.609 +	PRINT((_L("CVDecTestEngine::GetBitstreamCountersL Out")))
   1.610 +}
   1.611 +
   1.612 +/* ----------------------------------------------------------------------------
   1.613 +* Name:       CVDecTestEngine::PreDecoderBufferBytes()
   1.614 +* Purpose:
   1.615 +* Parameters:
   1.616 +*
   1.617 +* Return:     None
   1.618 +* --------------------------------------------------------------------------*/
   1.619 +
   1.620 +void CVDecTestEngine::PreDecoderBufferBytes()
   1.621 +{
   1.622 +	PRINT((_L("CVDecTestEngine::PreDecoderBufferBytes, In")))
   1.623 +
   1.624 +	TUint lBufferBytes = iDevvp->PreDecoderBufferBytes();
   1.625 +	PRINT((_L("CVDecTestEngine::PreDecoderBufferBytes, Number of bytes of data in the pre-decoder buffer = %d"), lBufferBytes))
   1.626 +
   1.627 +	PRINT((_L("CVDecTestEngine::PreDecoderBufferBytes, Out")))
   1.628 +}
   1.629 +
   1.630 +/* ----------------------------------------------------------------------------
   1.631 +* Name:       CVDecTestEngine::PictureBufferBytes()
   1.632 +* Purpose:
   1.633 +* Parameters:
   1.634 +*
   1.635 +* Return:     None
   1.636 +* --------------------------------------------------------------------------*/
   1.637 +
   1.638 +void CVDecTestEngine::PictureBufferBytes()
   1.639 +{
   1.640 +	PRINT((_L("CVDecTestEngine::PictureBufferBytes, In")))
   1.641 +
   1.642 +	TUint buffbyte =  iDevvp->PictureBufferBytes();
   1.643 +	PRINT((_L("CVDecTestEngine::PictureBufferBytes: total amount of memory allocated [%d]"),buffbyte))
   1.644 +
   1.645 +	PRINT((_L("CVDecTestEngine::PictureBufferBytes, Out")))
   1.646 +}
   1.647 +
   1.648 +/* ----------------------------------------------------------------------------
   1.649 +* Name:       CVDecTestEngine::SetPostProcessTypesL()
   1.650 +* Purpose:    Set combination of postprocessor
   1.651 +*
   1.652 +* Parameters: TUint32 aCombination
   1.653 +* Return:     None
   1.654 +* --------------------------------------------------------------------------*/
   1.655 +
   1.656 +void CVDecTestEngine::SetPostProcessTypesL(TInt aHWDevice, TUint32 aCombination)
   1.657 +{
   1.658 +	PRINT((_L("CVDecTestEngine::SetPostProcessTypesL, In")))
   1.659 +
   1.660 +	if (aHWDevice == EPostProcessor)
   1.661 +	{
   1.662 +		iDevvp->SetPostProcessTypesL(iPostProcId,aCombination);
   1.663 +	}
   1.664 +	else
   1.665 +	{
   1.666 +		iDevvp->SetPostProcessTypesL(iDecHWDevId,aCombination);
   1.667 +	}
   1.668 +
   1.669 +	PRINT((_L("CVDecTestEngine::SetPostProcessTypesL, Out")))
   1.670 +}
   1.671 +
   1.672 +
   1.673 +/* ----------------------------------------------------------------------------
   1.674 +* Name:       CVDecTestEngine::SetInputCropOptionsL()
   1.675 +* Purpose:    Set input crop
   1.676 +*
   1.677 +* Parameters: TRect aCrop
   1.678 +* Return:     None
   1.679 +* --------------------------------------------------------------------------*/
   1.680 +
   1.681 +void CVDecTestEngine::SetInputCropOptionsL(TInt aHWDevice, TRect aCrop)
   1.682 +{
   1.683 +	PRINT((_L("CVDecTestEngine::SetInputCropOptionsL, In")))
   1.684 +
   1.685 +	if (aHWDevice == EPostProcessor)
   1.686 +	{
   1.687 +		iDevvp->SetInputCropOptionsL(iPostProcId,aCrop);
   1.688 +	}
   1.689 +	else
   1.690 +	{
   1.691 +		iDevvp->SetInputCropOptionsL(iDecHWDevId,aCrop);
   1.692 +	}
   1.693 +
   1.694 +	PRINT((_L("CVDecTestEngine::SetInputCropOptionsL, Out")))
   1.695 +}
   1.696 +
   1.697 +/* ----------------------------------------------------------------------------
   1.698 +* Name:       CVDecTestEngine::SetYuvToRgbOptionsL()
   1.699 +* Purpose:    Set Yuv to Rgb options
   1.700 +*
   1.701 +* Parameters: TYuvToRgbOptions aOptions
   1.702 +* Return:     None
   1.703 +* --------------------------------------------------------------------------*/
   1.704 +
   1.705 +void CVDecTestEngine::SetYuvToRgbOptionsL(TInt aHWDevice, TYuvToRgbOptions aOptions)
   1.706 +{
   1.707 +	PRINT((_L("CVDecTestEngine::SetYuvToRgbOptionsL, In")))
   1.708 +
   1.709 +	if (aHWDevice == EPostProcessor)
   1.710 +	{
   1.711 +		iDevvp->SetYuvToRgbOptionsL(iPostProcId, aOptions);
   1.712 +	}
   1.713 +	else
   1.714 +	{
   1.715 +		iDevvp->SetYuvToRgbOptionsL(iDecHWDevId, aOptions);
   1.716 +	}
   1.717 +
   1.718 +	PRINT((_L("CVDecTestEngine::SetYuvToRgbOptionsL, Out")))
   1.719 +}
   1.720 +
   1.721 +
   1.722 +/* ----------------------------------------------------------------------------
   1.723 +* Name:       CVDecTestEngine::SetRotateOptionsL()
   1.724 +* Purpose:    Set Rotation
   1.725 +*
   1.726 +* Parameters: TRotationType aRotation
   1.727 +* Return:     None
   1.728 +* --------------------------------------------------------------------------*/
   1.729 +void CVDecTestEngine::SetRotateOptionsL(TInt aHWDevice, TRotationType aRotation)
   1.730 +{
   1.731 +	PRINT((_L("CVDecTestEngine::SetRotateOptionsL, In")))
   1.732 +
   1.733 +	if (aHWDevice == EPostProcessor)
   1.734 +	{
   1.735 +		iDevvp->SetRotateOptionsL(iPostProcId, aRotation);
   1.736 +	}
   1.737 +	else
   1.738 +	{
   1.739 +		iDevvp->SetRotateOptionsL(iDecHWDevId, aRotation);
   1.740 +	}
   1.741 +
   1.742 +	PRINT((_L("CVDecTestEngine::SetRotateOptionsL, Out")))
   1.743 +}
   1.744 +
   1.745 +
   1.746 +/* ----------------------------------------------------------------------------
   1.747 +* Name:       CVDecTestEngine::SetScaleOptionsL()
   1.748 +* Purpose:    Set Scale with multiply factor
   1.749 +*
   1.750 +* Parameters: TSize aSize, TBool aAntiAliasFiltering
   1.751 +* Return:     None
   1.752 +* --------------------------------------------------------------------------*/
   1.753 +void CVDecTestEngine::SetScaleOptionsL(TInt aHWDevice, TSize aSize, TBool aAntiAliasFiltering)
   1.754 +{
   1.755 +	PRINT((_L("CVDecTestEngine::SetScaleOptionsL, In")));
   1.756 +
   1.757 +	if (aHWDevice == EPostProcessor)
   1.758 +	{
   1.759 +		iDevvp->SetScaleOptionsL(iPostProcId, aSize, aAntiAliasFiltering);
   1.760 +	}
   1.761 +	else
   1.762 +	{
   1.763 +		iDevvp->SetScaleOptionsL(iDecHWDevId, aSize, aAntiAliasFiltering);
   1.764 +	}
   1.765 +
   1.766 +	PRINT((_L("CVDecTestEngine::SetScaleOptionsL, Scale option is set:width[%d],height[%d]"), aSize.iWidth,aSize.iHeight))
   1.767 +
   1.768 +	PRINT((_L("CVDecTestEngine::SetScaleOptionsL, Out")));
   1.769 +}
   1.770 +
   1.771 +/* ----------------------------------------------------------------------------
   1.772 +* Name:       CVDecTestEngine::SetScaleOptionsL()
   1.773 +* Purpose:    Set Scale with multiply factor
   1.774 +*
   1.775 +* Parameters: TInt aNumFactor,TInt aDenoFactor, TBool aAntiAliasFiltering
   1.776 +* Return:     None
   1.777 +* --------------------------------------------------------------------------*/
   1.778 +void CVDecTestEngine::SetScaleOptionsL(TInt aNumFactor,TInt aDenoFactor, TBool aAntiAliasFiltering)
   1.779 +{
   1.780 +	PRINT((_L("CVDecTestEngine::SetScaleOptionsL, Out")));
   1.781 +
   1.782 +	TInt width =  static_cast<TInt>(iPictureSize.iWidth*aNumFactor/aDenoFactor);
   1.783 +	TInt height = static_cast<TInt>(iPictureSize.iHeight*aNumFactor/aDenoFactor);
   1.784 +
   1.785 +	TSize target(width, height);
   1.786 +
   1.787 +	iDevvp->SetScaleOptionsL(iPostProcId, target, aAntiAliasFiltering);
   1.788 +	PRINT((_L("CVDecTestEngine::SetScaleOptionsL, Scale option is set:width[%d],height[%d]"),target.iWidth,target.iHeight))
   1.789 +
   1.790 +	PRINT((_L("CVDecTestEngine::SetScaleOptionsL, Out")));
   1.791 +}
   1.792 +
   1.793 +
   1.794 +/* ----------------------------------------------------------------------------
   1.795 +* Name:       CVDecTestEngine::SetOutputCropOptionsL()
   1.796 +* Purpose:    Set output crop
   1.797 +*
   1.798 +* Parameters: TRect aCrop
   1.799 +* Return:     None
   1.800 +* --------------------------------------------------------------------------*/
   1.801 +void CVDecTestEngine::SetOutputCropOptionsL(TInt aHWDevice, TRect aCrop)
   1.802 +{
   1.803 +	PRINT((_L("CVDecTestEngine::SetOutputCropOptionsL, In")));
   1.804 +
   1.805 +	if (aHWDevice == EPostProcessor)
   1.806 +	{
   1.807 +		iDevvp->SetOutputCropOptionsL(iPostProcId, aCrop);
   1.808 +	}
   1.809 +	else
   1.810 +	{
   1.811 +		iDevvp->SetOutputCropOptionsL(iDecHWDevId, aCrop);
   1.812 +	}
   1.813 +
   1.814 +	PRINT((_L("CVDecTestEngine::SetOutputCropOptionsL, Out")));
   1.815 +}
   1.816 +
   1.817 +
   1.818 +/* ----------------------------------------------------------------------------
   1.819 +* Name:       CVDecTestEngine::CommitL()
   1.820 +* Purpose:    commit change of postprocessors after intialization or revert
   1.821 +*
   1.822 +* Parameters: None
   1.823 +* Return:     None
   1.824 +* --------------------------------------------------------------------------*/
   1.825 +
   1.826 +void CVDecTestEngine::CommitL()
   1.827 +{
   1.828 +	PRINT((_L("CVDecTestEngine::CommitL, In")));
   1.829 +
   1.830 +	iDevvp->CommitL();
   1.831 +
   1.832 +	PRINT((_L("CVDecTestEngine::CommitL, Out")));
   1.833 +}
   1.834 +
   1.835 +/* ----------------------------------------------------------------------------
   1.836 +* Name:       CVDecTestEngine::Revert()
   1.837 +* Purpose:    Revert any configuration changes that have not yet been committed
   1.838 +*
   1.839 +* Parameters: None
   1.840 +* Return:     None
   1.841 +* --------------------------------------------------------------------------*/
   1.842 +void CVDecTestEngine::Revert()
   1.843 +{
   1.844 +	PRINT((_L("CVDecTestEngine::Revert, In")));
   1.845 +
   1.846 +	iDevvp->Revert();
   1.847 +
   1.848 +	PRINT((_L("CVDecTestEngine::Revert, Out")));
   1.849 +}
   1.850 +
   1.851 +/* ----------------------------------------------------------------------------
   1.852 +* Name:       CVDecTestEngine::SetClockSource()
   1.853 +* Purpose:    Set SetHrdVbvSpec
   1.854 +* Note:       This is called before initilaized
   1.855 +* Parameters: THrdVbvSpecification aHrdVbvSpec
   1.856 +* Return:     None
   1.857 +* --------------------------------------------------------------------------*/
   1.858 +
   1.859 +void CVDecTestEngine::SetClockSource()
   1.860 +{
   1.861 +	PRINT((_L("CVDecTestEngine::SetClockSource, In")))
   1.862 +
   1.863 +	iDevvp->SetClockSource(iClock);
   1.864 +
   1.865 +	PRINT((_L("CVDecTestEngine::SetClockSource, Out")))
   1.866 +}
   1.867 +
   1.868 +/* ----------------------------------------------------------------------------
   1.869 +* Name:       CVDecTestEngine::SetHrdVbvSpec()
   1.870 +* Purpose:    Set SetHrdVbvSpec
   1.871 +* Note:       This is called before initilaized
   1.872 +* Parameters: THrdVbvSpecification aHrdVbvSpec
   1.873 +* Return:     None
   1.874 +* --------------------------------------------------------------------------*/
   1.875 +
   1.876 +void CVDecTestEngine::SetHrdVbvSpec(THrdVbvSpecification aHrdVbvSpec, const TDesC8& aHrdVbvParams)
   1.877 +{
   1.878 +	PRINT((_L("CVDecTestEngine::SetHrdVbvSpec, In")))
   1.879 +
   1.880 +	iDevvp->SetHrdVbvSpec(aHrdVbvSpec, aHrdVbvParams);
   1.881 +
   1.882 +	PRINT((_L("CVDecTestEngine::SetHrdVbvSpec, Out")))
   1.883 +}
   1.884 +
   1.885 +/* ----------------------------------------------------------------------------
   1.886 +* Name:       CVDecTestEngine::SetPostProcSpecificOptionsL()
   1.887 +* Purpose:    Set SetHrdVbvSpec
   1.888 +* Note:       This is called before initilaized
   1.889 +* Parameters: THrdVbvSpecification aHrdVbvSpec
   1.890 +* Return:     None
   1.891 +* --------------------------------------------------------------------------*/
   1.892 +
   1.893 +void CVDecTestEngine::SetPostProcSpecificOptionsL(TInt aHWDevice, const TDesC8& aOptions)
   1.894 +{
   1.895 +	PRINT((_L("CVDecTestEngine::SetPostProcSpecificOptionsL, In")))
   1.896 +
   1.897 +	if (aHWDevice == EPostProcessor)
   1.898 +	{
   1.899 +		iDevvp->SetPostProcSpecificOptionsL(iPostProcId, aOptions);
   1.900 +	}
   1.901 +	else
   1.902 +	{
   1.903 +		iDevvp->SetPostProcSpecificOptionsL(iDecHWDevId, aOptions);
   1.904 +	}
   1.905 +
   1.906 +	PRINT((_L("CVDecTestEngine::SetPostProcSpecificOptionsL, Out")))
   1.907 +}
   1.908 +
   1.909 +/* ----------------------------------------------------------------------------
   1.910 +* Name:       CVDecTestEngine::SetScreenClipRegion()
   1.911 +* Purpose:    Set SetHrdVbvSpec
   1.912 +* Note:       This is called before initilaized
   1.913 +* Parameters: THrdVbvSpecification aHrdVbvSpec
   1.914 +* Return:     None
   1.915 +* --------------------------------------------------------------------------*/
   1.916 +
   1.917 +void CVDecTestEngine::SetScreenClipRegion(TRegion& aRegion)
   1.918 +{
   1.919 +	PRINT((_L("CVDecTestEngine::SetScreenClipRegion, In")))
   1.920 +
   1.921 +	iDevvp->SetScreenClipRegion(aRegion);
   1.922 +
   1.923 +	PRINT((_L("CVDecTestEngine::SetScreenClipRegion, Out")))
   1.924 +}
   1.925 +
   1.926 +/* ----------------------------------------------------------------------------
   1.927 +* Name:       CVDecTestEngine::SetPauseOnClipFail()
   1.928 +* Purpose:    Set SetHrdVbvSpec
   1.929 +* Note:       This is called before initilaized
   1.930 +* Parameters: THrdVbvSpecification aHrdVbvSpec
   1.931 +* Return:     None
   1.932 +* --------------------------------------------------------------------------*/
   1.933 +
   1.934 +void CVDecTestEngine::SetPauseOnClipFail(TBool aPause)
   1.935 +{
   1.936 +	PRINT((_L("CVDecTestEngine::SetPauseOnClipFail, In")))
   1.937 +
   1.938 +	iDevvp->SetPauseOnClipFail(aPause);
   1.939 +
   1.940 +	PRINT((_L("CVDecTestEngine::SetPauseOnClipFail, Out")))
   1.941 +}
   1.942 +
   1.943 +/* ----------------------------------------------------------------------------
   1.944 +* Name:       CVDecTestEngine::IsPlaying()
   1.945 +* Purpose:    Set SetHrdVbvSpec
   1.946 +* Note:       This is called before initilaized
   1.947 +* Parameters: THrdVbvSpecification aHrdVbvSpec
   1.948 +* Return:     None
   1.949 +* --------------------------------------------------------------------------*/
   1.950 +
   1.951 +void CVDecTestEngine::IsPlaying()
   1.952 +{
   1.953 +	PRINT((_L("CVDecTestEngine::IsPlaying, In")))
   1.954 +
   1.955 +	TUint playing = iDevvp->IsPlaying();
   1.956 +	PRINT((_L("CVDecTestEngine::IsPlaying, [%d]"), playing))
   1.957 +
   1.958 +	PRINT((_L("CVDecTestEngine::IsPlaying, Out")))
   1.959 +
   1.960 +}
   1.961 +
   1.962 +/* ----------------------------------------------------------------------------
   1.963 +* Name:       CVDecTestEngine::GetPictureCounters()
   1.964 +* Purpose:    Set SetHrdVbvSpec
   1.965 +* Note:       This is called before initilaized
   1.966 +* Parameters: THrdVbvSpecification aHrdVbvSpec
   1.967 +* Return:     None
   1.968 +* --------------------------------------------------------------------------*/
   1.969 +
   1.970 +void CVDecTestEngine::GetPictureCounters()
   1.971 +{
   1.972 +	PRINT((_L("CVDecTestEngine::GetPictureCounters, In")))
   1.973 +
   1.974 +	CMMFDevVideoPlay::TPictureCounters counters;
   1.975 +	iDevvp->GetPictureCounters(counters);
   1.976 +
   1.977 +	PRINT((_L("CVDecTestEngine::GetPictureCounters, iPicturesSkipped, [%d]"), counters.iPicturesSkipped))
   1.978 +	PRINT((_L("CVDecTestEngine::GetPictureCounters, iPicturesDecoded, [%d]"), counters.iPicturesDecoded))
   1.979 +	PRINT((_L("CVDecTestEngine::GetPictureCounters, iPicturesDisplayed, [%d]"), counters.iPicturesDisplayed))
   1.980 +	PRINT((_L("CVDecTestEngine::GetPictureCounters, iTotalPictures, [%d]"), counters.iTotalPictures))
   1.981 +
   1.982 +	PRINT((_L("CVDecTestEngine::GetPictureCounters, Out")))
   1.983 +}
   1.984 +
   1.985 +/* ----------------------------------------------------------------------------
   1.986 +* Name:       CVDecTestEngine::NumFreeBuffers()
   1.987 +* Purpose:    Set SetHrdVbvSpec
   1.988 +* Note:       This is called before initilaized
   1.989 +* Parameters: THrdVbvSpecification aHrdVbvSpec
   1.990 +* Return:     None
   1.991 +* --------------------------------------------------------------------------*/
   1.992 +
   1.993 +void CVDecTestEngine::NumFreeBuffers()
   1.994 +{
   1.995 +	PRINT((_L("CVDecTestEngine::NumFreeBuffers, In")))
   1.996 +
   1.997 +	TUint playing = iDevvp->NumFreeBuffers();
   1.998 +	PRINT((_L("CVDecTestEngine::NumFreeBuffers, [%d]"), playing))
   1.999 +
  1.1000 +	PRINT((_L("CVDecTestEngine::NumFreeBuffers, Out")))
  1.1001 +
  1.1002 +}
  1.1003 +
  1.1004 +/* ----------------------------------------------------------------------------
  1.1005 +* Name:       CVDecTestEngine::NumComplexityLevels()
  1.1006 +* Purpose:    Set SetHrdVbvSpec
  1.1007 +* Note:       This is called before initilaized
  1.1008 +* Parameters: THrdVbvSpecification aHrdVbvSpec
  1.1009 +* Return:     None
  1.1010 +* --------------------------------------------------------------------------*/
  1.1011 +
  1.1012 +void CVDecTestEngine::NumComplexityLevels(TInt aHWDevice)
  1.1013 +{
  1.1014 +	PRINT((_L("CVDecTestEngine::NumComplexityLevels, In")))
  1.1015 +
  1.1016 +	TUint number = 0;
  1.1017 +	if (aHWDevice == EPostProcessor)
  1.1018 +	{
  1.1019 +		number = iDevvp->NumComplexityLevels(iPostProcId);
  1.1020 +	}
  1.1021 +	else
  1.1022 +	{
  1.1023 +		number = iDevvp->NumComplexityLevels(iDecHWDevId);
  1.1024 +	}
  1.1025 +
  1.1026 +	PRINT((_L("CVDecTestEngine::NumComplexityLevels, [%d]"), number))
  1.1027 +
  1.1028 +	PRINT((_L("CVDecTestEngine::NumComplexityLevels, Out")))
  1.1029 +}
  1.1030 +
  1.1031 +/* ----------------------------------------------------------------------------
  1.1032 +* Name:       CVDecTestEngine::InputEnd()
  1.1033 +* Purpose:    Set SetHrdVbvSpec
  1.1034 +* Note:       This is called before initilaized
  1.1035 +* Parameters: THrdVbvSpecification aHrdVbvSpec
  1.1036 +* Return:     None
  1.1037 +* --------------------------------------------------------------------------*/
  1.1038 +
  1.1039 +void CVDecTestEngine::InputEnd()
  1.1040 +{
  1.1041 +	PRINT((_L("CVDecTestEngine::InputEnd, In")))
  1.1042 +
  1.1043 +	iDevvp->InputEnd();
  1.1044 +
  1.1045 +	PRINT((_L("CVDecTestEngine::InputEnd, Out")))
  1.1046 +}
  1.1047 +
  1.1048 +/* ----------------------------------------------------------------------------
  1.1049 +* Name:       CVDecTestEngine::GetNewPictureInfo()
  1.1050 +* Purpose:    Set SetHrdVbvSpec
  1.1051 +* Note:       This is called before initilaized
  1.1052 +* Parameters: THrdVbvSpecification aHrdVbvSpec
  1.1053 +* Return:     None
  1.1054 +* --------------------------------------------------------------------------*/
  1.1055 +
  1.1056 +void CVDecTestEngine::GetNewPictureInfo(TTimeIntervalMicroSeconds& aEarliestTimestamp,
  1.1057 +TTimeIntervalMicroSeconds& aLatestTimestamp)
  1.1058 +{
  1.1059 +	PRINT((_L("CVDecTestEngine::GetNewPictureInfo, In")))
  1.1060 +
  1.1061 +	TUint numbers = 0;
  1.1062 +	iDevvp->GetNewPictureInfo(numbers, aEarliestTimestamp, aLatestTimestamp);
  1.1063 +	PRINT((_L("CVDecTestEngine::GetNewPictureInfo, [%d]"), numbers))
  1.1064 +
  1.1065 +	PRINT((_L("CVDecTestEngine::GetNewPictureInfo, Out")))
  1.1066 +}
  1.1067 +
  1.1068 +
  1.1069 +/* ----------------------------------------------------------------------------
  1.1070 +* Name:       CVDecTestEngine::GetTimedSnapshotL()
  1.1071 +* Purpose:    Set SetHrdVbvSpec
  1.1072 +* Note:       This is called before initilaized
  1.1073 +* Parameters: THrdVbvSpecification aHrdVbvSpec
  1.1074 +* Return:     None
  1.1075 +* --------------------------------------------------------------------------*/
  1.1076 +
  1.1077 +void CVDecTestEngine::GetTimedSnapshotL(const TUncompressedVideoFormat& aFormat,
  1.1078 +const TTimeIntervalMicroSeconds& aPresentationTimestamp)
  1.1079 +{
  1.1080 +	PRINT((_L("CVDecTestEngine::GetTimedSnapshotL, In")))
  1.1081 +
  1.1082 +	iPictureDataSnapshot.iDataFormat = aFormat.iDataFormat;
  1.1083 +	iPictureDataSnapshot.iDataSize = iPictureSize;
  1.1084 +
  1.1085 +	PrintUncompressedFormat(aFormat);
  1.1086 +
  1.1087 +	iDevvp->GetTimedSnapshotL(&iPictureDataSnapshot, aFormat, aPresentationTimestamp);
  1.1088 +
  1.1089 +	PRINT((_L("CVDecTestEngine::GetTimedSnapshotL, Out")))
  1.1090 +}
  1.1091 +
  1.1092 +/* ----------------------------------------------------------------------------
  1.1093 +* Name:       CVDecTestEngine::GetTimedSnapshotL()
  1.1094 +* Purpose:    Set SetHrdVbvSpec
  1.1095 +* Note:       This is called before initilaized
  1.1096 +* Parameters: THrdVbvSpecification aHrdVbvSpec
  1.1097 +* Return:     None
  1.1098 +* --------------------------------------------------------------------------*/
  1.1099 +
  1.1100 +void CVDecTestEngine::GetTimedSnapshotL(const TUncompressedVideoFormat& aFormat,
  1.1101 +const TPictureId& aPictureId)
  1.1102 +{
  1.1103 +	PRINT((_L("CVDecTestEngine::GetTimedSnapshotL, In")))
  1.1104 +
  1.1105 +	iPictureDataSnapshot.iDataFormat = aFormat.iDataFormat;
  1.1106 +	iPictureDataSnapshot.iDataSize = iPictureSize;
  1.1107 +
  1.1108 +	PrintUncompressedFormat(aFormat);
  1.1109 +
  1.1110 +	iDevvp->GetTimedSnapshotL(&iPictureDataSnapshot, aFormat, aPictureId);
  1.1111 +
  1.1112 +	PRINT((_L("CVDecTestEngine::GetTimedSnapshotL, Out")))
  1.1113 +}
  1.1114 +
  1.1115 +/* ----------------------------------------------------------------------------
  1.1116 +* Name:       CVDecTestEngine::CancelTimedSnapshot()
  1.1117 +* Purpose:    Set SetHrdVbvSpec
  1.1118 +* Note:       This is called before initilaized
  1.1119 +* Parameters: THrdVbvSpecification aHrdVbvSpec
  1.1120 +* Return:     None
  1.1121 +* --------------------------------------------------------------------------*/
  1.1122 +
  1.1123 +void CVDecTestEngine::CancelTimedSnapshot()
  1.1124 +{
  1.1125 +	PRINT((_L("CVDecTestEngine::CancelTimedSnapshot, In")))
  1.1126 +
  1.1127 +	iDevvp->CancelTimedSnapshot();
  1.1128 +
  1.1129 +	PRINT((_L("CVDecTestEngine::CancelTimedSnapshot, Out")))
  1.1130 +}
  1.1131 +
  1.1132 +/* ----------------------------------------------------------------------------
  1.1133 +* Name:       CVDecTestEngine::GetSupportedSnapshotFormatsL()
  1.1134 +* Purpose:    Set SetHrdVbvSpec
  1.1135 +* Note:       This is called before initilaized
  1.1136 +* Parameters: THrdVbvSpecification aHrdVbvSpec
  1.1137 +* Return:     None
  1.1138 +* --------------------------------------------------------------------------*/
  1.1139 +
  1.1140 +void CVDecTestEngine::GetSupportedSnapshotFormatsL()
  1.1141 +{
  1.1142 +	PRINT((_L("CVDecTestEngine::GetSupportedSnapshotFormatsL, In")))
  1.1143 +
  1.1144 +	RArray<TUncompressedVideoFormat> formats;
  1.1145 +	CleanupClosePushL(formats);
  1.1146 +
  1.1147 +	iDevvp->GetSupportedSnapshotFormatsL(formats);
  1.1148 +
  1.1149 +	for (TUint i = 0; i < formats.Count(); i++)
  1.1150 +	{
  1.1151 +		PRINT((_L("CVDecTestEngine::GetSupportedSnapshotFormatsL, Format No.%d"), i))
  1.1152 +		PrintUncompressedFormat(formats[i]);
  1.1153 +	}
  1.1154 +	CleanupStack::PopAndDestroy(&formats);
  1.1155 +
  1.1156 +	PRINT((_L("CVDecTestEngine::GetSupportedSnapshotFormatsL, Out")))
  1.1157 +}
  1.1158 +
  1.1159 +
  1.1160 +/* ----------------------------------------------------------------------------
  1.1161 +* Name:       CVDecTestEngine::SetComplexityLevel()
  1.1162 +* Purpose:    Set Complexity Level of Decode and postprocessor
  1.1163 +* Note:       This is called after initilaized
  1.1164 +* Parameters: TInt aDecLevel, TInt aPostProcLevel
  1.1165 +* Return:     None
  1.1166 +* --------------------------------------------------------------------------*/
  1.1167 +
  1.1168 +void CVDecTestEngine::SetComplexityLevel(TInt aHWDevice, TInt aLevel)
  1.1169 +{
  1.1170 +	PRINT((_L("CVDecTestEngine::SetComplexityLevel, In")))
  1.1171 +
  1.1172 +	if (aHWDevice == EPostProcessor)
  1.1173 +	{
  1.1174 +		iDevvp->SetComplexityLevel(iPostProcId, aLevel);
  1.1175 +	}
  1.1176 +	else
  1.1177 +	{
  1.1178 +		iDevvp->SetComplexityLevel(iDecHWDevId, aLevel);
  1.1179 +	}
  1.1180 +
  1.1181 +	PRINT((_L("CVDecTestEngine::SetComplexityLevel, Out")))
  1.1182 +}
  1.1183 +
  1.1184 +
  1.1185 +
  1.1186 +/* ----------------------------------------------------------------------------
  1.1187 +* Name:       CVDecTestEngine::GetComplexityLevelInfo()
  1.1188 +* Purpose:    Get number and information of Complexity Level of Decode and postprocessor
  1.1189 +* Note:       This is called after initilaized
  1.1190 +* Parameters: None
  1.1191 +* Return:     None
  1.1192 +* --------------------------------------------------------------------------*/
  1.1193 +
  1.1194 +void CVDecTestEngine::GetComplexityLevelInfo(TInt aHWDevice, TInt aLevel)
  1.1195 +{
  1.1196 +	PRINT((_L("CVDecTestEngine::GetComplexityLevelInfo, In")))
  1.1197 +
  1.1198 +	CMMFDevVideoPlay::TComplexityLevelInfo info;
  1.1199 +
  1.1200 +	if (aHWDevice == EPostProcessor)
  1.1201 +	{
  1.1202 +		iDevvp->GetComplexityLevelInfo(iPostProcId, aLevel, info);
  1.1203 +	}
  1.1204 +	else
  1.1205 +	{
  1.1206 +		iDevvp->GetComplexityLevelInfo(iDecHWDevId, aLevel, info);
  1.1207 +	}
  1.1208 +
  1.1209 +	PRINT((_L("CVDecTestEngine::GetComplexityLevelInfo, dec complexy level info[%x]"),info.iOptions))
  1.1210 +	PRINT((_L("CVDecTestEngine::GetComplexityLevelInfo, iAvgPictureRate [%f]"),info.iAvgPictureRate))
  1.1211 +	PRINT((_L("CVDecTestEngine::GetComplexityLevelInfo, iPictureSize width [%d] height[%d]"),info.iPictureSize.iWidth, info.iPictureSize.iHeight))
  1.1212 +	PRINT((_L("CVDecTestEngine::GetComplexityLevelInfo, iRelativeImageQuality [%f]"),info.iRelativeImageQuality))
  1.1213 +	PRINT((_L("CVDecTestEngine::GetComplexityLevelInfo, iRequiredMIPS [%d]"),info.iRequiredMIPS))
  1.1214 +	PRINT((_L("CVDecTestEngine::GetComplexityLevelInfo, iRelativeProcessTime [%f]"),info.iRelativeProcessTime))
  1.1215 +
  1.1216 +	PRINT((_L("CVDecTestEngine::GetComplexityLevelInfo, Out")))
  1.1217 +}
  1.1218 +
  1.1219 +
  1.1220 +/* ----------------------------------------------------------------------------
  1.1221 +* Name:       CVDecTestEngine::Redraw()
  1.1222 +* Purpose:    Redraw latest picture
  1.1223 +* Note:       only applicable when DSA is used and after initilaized
  1.1224 +* Parameters: None
  1.1225 +* Return:     None
  1.1226 +* --------------------------------------------------------------------------*/
  1.1227 +
  1.1228 +void CVDecTestEngine::Redraw()
  1.1229 +{
  1.1230 +	PRINT((_L("CVDecTestEngine::Redraw, In")))
  1.1231 +
  1.1232 +	iDevvp->Redraw();
  1.1233 +
  1.1234 +	PRINT((_L("CVDecTestEngine::Redraw, Out")))
  1.1235 +}
  1.1236 +
  1.1237 +
  1.1238 +
  1.1239 +/* ----------------------------------------------------------------------------
  1.1240 +* Name:       CVDecTestEngine::GetSnapshotL()
  1.1241 +* Purpose:
  1.1242 +* Note:
  1.1243 +* Parameters: None
  1.1244 +* Return:     None
  1.1245 +* --------------------------------------------------------------------------*/
  1.1246 +
  1.1247 +void CVDecTestEngine::GetSnapshotL(TUncompressedVideoFormat& aFormat)
  1.1248 +{
  1.1249 +	PRINT((_L("CVDecTestEngine::GetSnapshotL, In")))
  1.1250 +
  1.1251 +	TInt result;
  1.1252 +	TInt err = KErrNone;
  1.1253 +
  1.1254 +	TPictureData picture;
  1.1255 +
  1.1256 +	picture.iDataFormat = aFormat.iDataFormat;
  1.1257 +	picture.iDataSize = iPictureSize;
  1.1258 +
  1.1259 +	PRINT((_L("CVDecTestEngine::GetSnapshotL, before new []")))
  1.1260 +	TUint8* data = new (ELeave)TUint8[iPictureSize.iWidth*iPictureSize.iHeight*2];
  1.1261 +	PRINT((_L("CVDecTestEngine::GetSnapshotL, after new[]")))
  1.1262 +
  1.1263 +	TPtr8 dataPtr(data, iPictureSize.iWidth*iPictureSize.iHeight*2);
  1.1264 +	picture.iRawData = &dataPtr;
  1.1265 +
  1.1266 +	CleanupStack::PushL(data);
  1.1267 +	iMemAlloc++;
  1.1268 +	#ifdef __MEM_CHECK_
  1.1269 +	PRINT((_L("CVDecTestEngine::GetSnapshotL, mem alloc, data") ))
  1.1270 +	#endif
  1.1271 +	PRINT((_L("CVDecTestEngine::GetSnapshotL, before snapshot")))
  1.1272 +	result = iDevvp->GetSnapshotL(picture, aFormat);
  1.1273 +
  1.1274 +	PRINT((_L("CVDecTestEngine::GetSnapshotL, snapshot received")))
  1.1275 +	if ( !result )
  1.1276 +	{
  1.1277 +		RFile snapshot;
  1.1278 +
  1.1279 +		TFileName filename;
  1.1280 +		TBuf8<128> newFile;
  1.1281 +		newFile.Append(iInFileName);
  1.1282 +		TBuf16<128> temp2;
  1.1283 +		temp2.Copy(newFile);
  1.1284 +		PRINT((_L("CVDecTestEngine::GetSnapshotL, Opening the file [%S]"), &temp2))
  1.1285 +		newFile.Delete(newFile.Length()-4, 4);
  1.1286 +		newFile.Append(_L8("_snapshot"));
  1.1287 +		newFile.Append(_L8(".yuv"));
  1.1288 +		filename.Copy(newFile);
  1.1289 +
  1.1290 +		TBuf16<128> temp;
  1.1291 +		temp.Copy(newFile);
  1.1292 +
  1.1293 +		PRINT((_L("CVDecTestEngine::GetSnapshotL, Opening the file [%S]"), &temp))
  1.1294 +		err = snapshot.Replace(iFs, filename, EFileShareExclusive|EFileWrite);
  1.1295 +
  1.1296 +		PRINT((_L("CVDecTestEngine::GetSnapshotL, writing the file")))
  1.1297 +
  1.1298 +		if ( err!= KErrNone )
  1.1299 +		{
  1.1300 +			PRINT((_L("CVDecTestEngine::GetSnapshotL, snapshot file open failed")))
  1.1301 +			snapshot.Close();
  1.1302 +			User::Leave(err);
  1.1303 +		}
  1.1304 +		else
  1.1305 +		{
  1.1306 +			PRINT((_L("CVDecTestEngine::GetSnapshotL, Picture size %d"),picture.iRawData->Size()));
  1.1307 +			PRINT((_L("CVDecTestEngine::GetSnapshotL, Picture length %d"),picture.iRawData->Length()));
  1.1308 +			err = snapshot.Write(*(picture.iRawData),picture.iRawData->Size());
  1.1309 +			if ( err!= KErrNone )
  1.1310 +			{
  1.1311 +				PRINT((_L("CVDecTestEngine::GetSnapshotL, snapshot file write failed [%d]"), picture.iRawData->Size()))
  1.1312 +				snapshot.Close();
  1.1313 +				User::Leave(err);
  1.1314 +			}
  1.1315 +		}
  1.1316 +		PRINT((_L("CVDecTestEngine::GetSnapshotL, Picture size %d"),picture.iRawData->Size()));
  1.1317 +		snapshot.Close();
  1.1318 +
  1.1319 +	}
  1.1320 +	else
  1.1321 +	{
  1.1322 +		PRINT((_L("CVDecTestEngine::GetSnapshotL, Error getting snapshot [%d]"), result))
  1.1323 +	}
  1.1324 +	CleanupStack::PopAndDestroy( data );
  1.1325 +	iMemDelete++;
  1.1326 +	#ifdef __MEM_CHECK_
  1.1327 +	PRINT((_L("CVDecTestEngine::GetSnapShotL, mem del, ") ))
  1.1328 +	#endif
  1.1329 +	PRINT((_L("CVDecTestEngine::GetSnapshotL, Out")))
  1.1330 +}
  1.1331 +
  1.1332 +
  1.1333 +
  1.1334 +/* ----------------------------------------------------------------------------
  1.1335 +* Name:       CVDecTestEngine::OpenFileL()
  1.1336 +* Purpose:    Open input File
  1.1337 +* Note:       DSA is used, output is display
  1.1338 +* Parameters: TFileName& aInFileName
  1.1339 +* Return:     None
  1.1340 +* --------------------------------------------------------------------------*/
  1.1341 +
  1.1342 +void CVDecTestEngine::OpenFileL(TFileName& aInFileName)
  1.1343 +{
  1.1344 +	PRINT((_L("CVDecTestEngine::OpenFileL, In")))
  1.1345 +	TInt err;
  1.1346 +	iInFileName.Copy(aInFileName);
  1.1347 +
  1.1348 +	if ( (err = iInFile.Open(iFs, aInFileName, EFileRead | EFileShareReadersOnly)) != KErrNone)
  1.1349 +	{
  1.1350 +		PRINT((_L("CVDecTestEngine::OpenFiles, Input File open Failed")));
  1.1351 +		User::Leave(err);
  1.1352 +	}
  1.1353 +	PRINT((_L("CVDecTestEngine::OpenFileL, Out")))
  1.1354 +}
  1.1355 +
  1.1356 +
  1.1357 +/* ----------------------------------------------------------------------------
  1.1358 +* Name:       CVDecTestEngine::OpenFileL()
  1.1359 +* Purpose:    Open input and output File
  1.1360 +* Note:       Memory buffer output is used
  1.1361 +* Parameters: TFileName& aOutFileName, TFileName& aInFileName
  1.1362 +* Return:     None
  1.1363 +* --------------------------------------------------------------------------*/
  1.1364 +
  1.1365 +
  1.1366 +void CVDecTestEngine::OpenFileL(TFileName& aOutFileName, TFileName& aInFileName)
  1.1367 +{
  1.1368 +	PRINT((_L("CVDecTestEngine::OpenFileL, In")))
  1.1369 +	TInt err = KErrNone;
  1.1370 +
  1.1371 +	iInFileName.Copy(aInFileName);
  1.1372 +	iOutFileName.Copy(aOutFileName);
  1.1373 +	err = iInFile.Open(iFs, aInFileName, EFileRead | EFileShareReadersOnly);
  1.1374 +
  1.1375 +	if ( err != KErrNone)
  1.1376 +	{
  1.1377 +		PRINT((_L("CVDecTestEngine::OpenFiles, Input File open Failed")));
  1.1378 +	}
  1.1379 +
  1.1380 +	else
  1.1381 +	{
  1.1382 +		iOutFileOpen = ETrue;
  1.1383 +		err = iOutFile.Replace(iFs, aOutFileName, EFileShareExclusive|EFileWrite);
  1.1384 +
  1.1385 +		if ( err!= KErrNone )
  1.1386 +		{
  1.1387 +			PRINT((_L("CVDecTestEngine::OpenFiles, Output File Replace Failed")));
  1.1388 +			iInFile.Close();
  1.1389 +		}
  1.1390 +	}
  1.1391 +
  1.1392 +
  1.1393 +	AssertTIntEqualL(KErrNone,err);
  1.1394 +	PRINT((_L("CVDecTestEngine::OpenFileL, Out")))
  1.1395 +}
  1.1396 +
  1.1397 +
  1.1398 +
  1.1399 +/* ----------------------------------------------------------------------------
  1.1400 +* Name:       CVDecTestEngine::CloseFile()
  1.1401 +* Purpose:    Close File
  1.1402 +* Note:
  1.1403 +* Parameters:
  1.1404 +* Return:     None
  1.1405 +* --------------------------------------------------------------------------*/
  1.1406 +
  1.1407 +
  1.1408 +void CVDecTestEngine::CloseFile()
  1.1409 +{
  1.1410 +
  1.1411 +	iInFile.Close();
  1.1412 +	if ( iOutFileOpen )
  1.1413 +	{
  1.1414 +		iOutFile.Close();
  1.1415 +
  1.1416 +		PRINT((_L("CVDecTestEngine::CloseFile, Output file closed")))
  1.1417 +	}
  1.1418 +
  1.1419 +	PRINT((_L("CVDecTestEngine::CloseFile, File Closed")))
  1.1420 +
  1.1421 +	if( iCorruptMarker )
  1.1422 +	{
  1.1423 +		iFs.Delete( iOutFileName );
  1.1424 +	}
  1.1425 +
  1.1426 +}
  1.1427 +
  1.1428 +
  1.1429 +
  1.1430 +/* ----------------------------------------------------------------------------
  1.1431 +* Name:       CVDecTestEngine::FrameJump()
  1.1432 +* Purpose:    Jump backward or forward a number of frames
  1.1433 +* Note:
  1.1434 +* Parameters: TInt aNumToJump
  1.1435 +* Return:     TInt
  1.1436 +* --------------------------------------------------------------------------*/
  1.1437 +TInt CVDecTestEngine::FrameJump(TInt aNumToJump )
  1.1438 +{
  1.1439 +	PRINT((_L("CVDecTestEngine::FrameJump, In")))
  1.1440 +	TInt err = KErrNone;
  1.1441 +
  1.1442 +	if ( iState == ERunning )
  1.1443 +	{
  1.1444 +		if ( iSynchronized )
  1.1445 +		{
  1.1446 +			iClock->Suspend();  //Stop Clock source
  1.1447 +		}
  1.1448 +
  1.1449 +
  1.1450 +		iDevvp->Pause();
  1.1451 +		iState = EPaused;
  1.1452 +		PRINT((_L("CVDecTestEngine::Pause(), Paused")))
  1.1453 +
  1.1454 +
  1.1455 +		iFrameJump = aNumToJump;
  1.1456 +
  1.1457 +
  1.1458 +		if( iFrameJump < 0 )
  1.1459 +		{
  1.1460 +			TInt startFrame = iSentBuffCount + iFrameJump;
  1.1461 +			if( startFrame < 0 )
  1.1462 +			{
  1.1463 +				PRINT((_L("CVDecTestEngine::FrameJump, bad argument")))
  1.1464 +				return KErrArgument;
  1.1465 +			}
  1.1466 +			else
  1.1467 +			{
  1.1468 +				iFrameJump = startFrame;
  1.1469 +			}
  1.1470 +		}
  1.1471 +		TInt beginningPos = 0;
  1.1472 +		iInFile.Seek(ESeekStart, beginningPos);
  1.1473 +		RArray<TInt> vFramesizes;
  1.1474 +		ListFrameSizeL( vFramesizes );
  1.1475 +
  1.1476 +		if( iFrameSizeList.Count() > iFrameJump )
  1.1477 +		{
  1.1478 +			TInt startPosition = 0;
  1.1479 +			for( TInt frameCounter = 0; frameCounter < iFrameSizeList.Count();
  1.1480 +			frameCounter++ )
  1.1481 +			{
  1.1482 +				startPosition += iFrameSizeList[ frameCounter ];
  1.1483 +			}
  1.1484 +			iInFile.Seek(ESeekStart,startPosition);
  1.1485 +		}
  1.1486 +		else
  1.1487 +		{
  1.1488 +			err = KErrGeneral;
  1.1489 +			PRINT((_L("CVDecTestEngine::FrameJump, iFrameSizeList.Count value:[%ld]"),iFrameSizeList.Count()))
  1.1490 +		}
  1.1491 +
  1.1492 +	}
  1.1493 +	else
  1.1494 +	{
  1.1495 +		err = KErrGeneral;
  1.1496 +	}
  1.1497 +
  1.1498 +	PRINT((_L("CVDecTestEngine::FrameJump, iFrameJump value:[%ld]"),iFrameJump))
  1.1499 +	PRINT((_L("CVDecTestEngine::FrameJump, Out")))
  1.1500 +
  1.1501 +	return err;
  1.1502 +}
  1.1503 +
  1.1504 +
  1.1505 +
  1.1506 +/* ----------------------------------------------------------------------------
  1.1507 +* Name:       CVDecTestEngine::SetFrameMatch()
  1.1508 +* Purpose:    The test case fails if input and output frame number doesn't
  1.1509 +*             match
  1.1510 +* Note:
  1.1511 +* Parameters: TBool aMatch
  1.1512 +* Return:     None
  1.1513 +* --------------------------------------------------------------------------*/
  1.1514 +void CVDecTestEngine::SetFrameMatch(TBool aMatch)
  1.1515 +{
  1.1516 +
  1.1517 +	iFrameMatch = aMatch;
  1.1518 +
  1.1519 +	PRINT((_L("CVDecTestEngine::SetFrameMatch, frame match is set")))
  1.1520 +}
  1.1521 +
  1.1522 +
  1.1523 +/* ----------------------------------------------------------------------------
  1.1524 +* Name:       CVDecTestEngine::Initialize()
  1.1525 +* Purpose:    Initilize Decoder/Postprocessor
  1.1526 +* Note:
  1.1527 +* Parameters: TBool aSynchronized
  1.1528 +* Return:     None
  1.1529 +* --------------------------------------------------------------------------*/
  1.1530 +
  1.1531 +
  1.1532 +TInt CVDecTestEngine::Initialize()
  1.1533 +{
  1.1534 +	PRINT((_L("CVDecTestEngine::Initialize, In")))
  1.1535 +
  1.1536 +	iError = KErrNone;
  1.1537 +
  1.1538 +	// Do Initialization
  1.1539 +	iDevvp->Initialize();
  1.1540 +	PRINT((_L("CVDecTestEngine::Initialize, Initialize() returned")))
  1.1541 +	if ( (iState != EInitialized) && (iError == KErrNone ) )
  1.1542 +	{
  1.1543 +		iScheduler = new (ELeave) CActiveSchedulerWait;
  1.1544 +		iMemAlloc++;
  1.1545 +		#ifdef __MEM_CHECK_
  1.1546 +		PRINT((_L("CVDecTestEngine::Initialize, mem alloc, iScheduler") ))
  1.1547 +		#endif
  1.1548 +		iRunning = ETrue;
  1.1549 +		iScheduler->Start();
  1.1550 +	}
  1.1551 +	PRINT((_L("CVDecTestEngine::Initialize, out: error[%d]"),iError))
  1.1552 +	return iError;
  1.1553 +}
  1.1554 +
  1.1555 +/* ----------------------------------------------------------------------------
  1.1556 +* Name:       CVDecTestEngine::InitializeAndDelete()
  1.1557 +* Purpose:    Initilize Decoder/Postprocessor
  1.1558 +* Note:
  1.1559 +* Parameters: TBool aSynchronized
  1.1560 +* Return:     None
  1.1561 +* --------------------------------------------------------------------------*/
  1.1562 +
  1.1563 +
  1.1564 +TInt CVDecTestEngine::InitializeAndDelete()
  1.1565 +{
  1.1566 +	PRINT((_L("CVDecTestEngine::InitializeAndDelete, In")))
  1.1567 +
  1.1568 +	iDeleteDecoderFromInitComp = ETrue;
  1.1569 +
  1.1570 +	TInt err = Initialize();
  1.1571 +
  1.1572 +	PRINT((_L("CVDecTestEngine::InitializeAndDelete, Out")))
  1.1573 +	return err;
  1.1574 +}
  1.1575 +
  1.1576 +/* ----------------------------------------------------------------------------
  1.1577 +* Name:       CVDecTestEngine::Start()
  1.1578 +* Purpose:    Start Decoding/Postprocessing
  1.1579 +* Note:
  1.1580 +* Parameters: None
  1.1581 +* Return:     None
  1.1582 +* --------------------------------------------------------------------------*/
  1.1583 +
  1.1584 +
  1.1585 +TInt CVDecTestEngine::Start(TBool aInputEnd)
  1.1586 +{
  1.1587 +
  1.1588 +	TInt err = KErrNone;
  1.1589 +	iDisableInputEnd = aInputEnd;
  1.1590 +	
  1.1591 +	PRINT((_L("CVDecTestEngine::Start, Devvideo play started")))
  1.1592 +
  1.1593 +	// Start DSA
  1.1594 +	if ( iDirectScreenAccess && !iDsaStarted )
  1.1595 +	{
  1.1596 +		TRAPD(err, StartDirectScreenAccessL());
  1.1597 +		if (err != KErrNone)
  1.1598 +		{
  1.1599 +			return err;
  1.1600 +		}
  1.1601 +
  1.1602 +	}
  1.1603 +
  1.1604 +    // Start DevVideoPlay
  1.1605 +    iDevvp->Start();
  1.1606 +    iState = ERunning;
  1.1607 +    
  1.1608 +	//Reset Clock at Stream Start
  1.1609 +	if ( iSynchronized )
  1.1610 +	{
  1.1611 +		TTimeIntervalMicroSeconds offset(KStartOffset);
  1.1612 +		Int64 time = offset.Int64();
  1.1613 +		iClock->Reset(offset);
  1.1614 +	}
  1.1615 +
  1.1616 +
  1.1617 +	// Start Data transfer
  1.1618 +	iDecTestAO->RequestData();
  1.1619 +
  1.1620 +	PRINT((_L("CVDecTestEngine::Start, Start data transfer - start () out")))
  1.1621 +	return err;
  1.1622 +
  1.1623 +}
  1.1624 +
  1.1625 +
  1.1626 +
  1.1627 +/* ----------------------------------------------------------------------------
  1.1628 +* Name:       CVDecTestEngine::Stop()
  1.1629 +* Purpose:    Stop Decoding/Postprocessing
  1.1630 +* Note:
  1.1631 +* Parameters: None
  1.1632 +* Return:     None
  1.1633 +* --------------------------------------------------------------------------*/
  1.1634 +
  1.1635 +
  1.1636 +TInt CVDecTestEngine::Stop()
  1.1637 +{
  1.1638 +
  1.1639 +	PRINT((_L("CVDecTestEngine::Stop, In ")))
  1.1640 +
  1.1641 +	if ( (iState == ERunning ) || (iState == EPaused) )
  1.1642 +	{
  1.1643 +		//Stop Devvideoplay
  1.1644 +        iDevvp->Stop();
  1.1645 +		iState = EStopped;
  1.1646 +		PRINT((_L("CVDecTestEngine::Stop, Stopped ")))
  1.1647 +	}
  1.1648 +
  1.1649 +	//Stop DSA
  1.1650 +	if ( iDirectScreenAccess && iDsaStarted )
  1.1651 +	{
  1.1652 +		iDevvp->AbortDirectScreenAccess();
  1.1653 +		iDsaStarted = EFalse;
  1.1654 +		PRINT((_L("CVDecTestEngine::Stop, DSA is aborted ")))
  1.1655 +
  1.1656 +		PRINT((_L("CVDecTestEngine::VDecTestStartL, the number of Pictures sent: [%d]"),iSentBuffCount))
  1.1657 +
  1.1658 +	}
  1.1659 +	else if ( iInputEnd )
  1.1660 +	{
  1.1661 +		if ( iSentBuffCount != (iReturnedBuffCount + iPictureLoss) )
  1.1662 +		{
  1.1663 +			if( iFrameMatch )
  1.1664 +			{
  1.1665 +				PRINT((_L("CVDecTestEngine::VDecTestStopL, the number of Pictures sent and returned does not match: ")))
  1.1666 +				return KErrGeneral;
  1.1667 +			}
  1.1668 +			PRINT((_L("CVDecTestEngine::VDecTestStopL, the number of Pictures sent and returned does not match: ")))
  1.1669 +			PRINT((_L("The number of pictures, sent : [%d], returned:[%d] "),iSentBuffCount, iReturnedBuffCount ))
  1.1670 +		}
  1.1671 +	}
  1.1672 +
  1.1673 +	PRINT((_L("CVDecTestEngine::Stop, Out")))
  1.1674 +	return iError;
  1.1675 +}
  1.1676 +
  1.1677 +
  1.1678 +
  1.1679 +/* ----------------------------------------------------------------------------
  1.1680 +* Name:       CVDecTestEngine::TearDown()
  1.1681 +* Purpose:    Cleanup resources
  1.1682 +* Note:
  1.1683 +* Parameters: None
  1.1684 +* Return:     None
  1.1685 +* --------------------------------------------------------------------------*/
  1.1686 +
  1.1687 +
  1.1688 +void CVDecTestEngine::TearDown()
  1.1689 +{
  1.1690 +	PRINT((_L("CVDecTestEngine::TearDown(),In")))
  1.1691 +
  1.1692 +	if( iInstantFpsEnabled )
  1.1693 +	{
  1.1694 +		iFpsFile.Close();
  1.1695 +		PRINT((_L("CVDecTestEngine::CloseFile, FPS Output file closed")))
  1.1696 +	}
  1.1697 +
  1.1698 +	if ( iDsaStarted )
  1.1699 +	{
  1.1700 +		iDevvp->AbortDirectScreenAccess();
  1.1701 +		PRINT((_L("CVDecTestEngine::TearDown(), Dsa aborted")))
  1.1702 +	}
  1.1703 +
  1.1704 +	// Delete Devvideo play
  1.1705 +	if ( iDevvp )
  1.1706 +	{
  1.1707 +		delete iDevvp;
  1.1708 +		iMemDelete++;
  1.1709 +		#ifdef __MEM_CHECK_
  1.1710 +		PRINT((_L("CVDecTestEngine::TearDown, mem del, iDevvp") ))
  1.1711 +		#endif
  1.1712 +		iDevvp = NULL;
  1.1713 +		iState = EStateNone;
  1.1714 +		PRINT((_L("CVDecTestEngine::TearDown(),DevVideo deleted")))
  1.1715 +	}
  1.1716 +
  1.1717 +
  1.1718 +	//Postproc input buffer
  1.1719 +	if ( !iCIBuffMgmtOn && iRawInBuffer)
  1.1720 +	{
  1.1721 +		delete (TUint8*)iRawInBuffer->iData.iRawData->Ptr();
  1.1722 +		delete iRawInBuffer->iData.iRawData;
  1.1723 +		delete iRawInBuffer;
  1.1724 +		iMemDelete += 3;
  1.1725 +		#ifdef __MEM_CHECK_
  1.1726 +		PRINT((_L("CVDecTestEngine::TearDown, mem del, iRawInBuffer & its 2 pointers") ))
  1.1727 +		#endif
  1.1728 +		iRawInBuffer = NULL;
  1.1729 +	}
  1.1730 +
  1.1731 +	if ( iScreenDevice )
  1.1732 +	{
  1.1733 +		delete iScreenDevice;
  1.1734 +		iScreenDevice = NULL;
  1.1735 +		iMemDelete++;
  1.1736 +		#ifdef __MEM_CHECK_
  1.1737 +		PRINT((_L("CVDecTestEngine::TearDown, mem del, iScreenDevice") ))
  1.1738 +		#endif
  1.1739 +		RFbsSession::Disconnect();
  1.1740 +	}
  1.1741 +
  1.1742 +	delete iDataChunk;
  1.1743 +	iMemDelete++;
  1.1744 +	#ifdef __MEM_CHECK_
  1.1745 +	PRINT((_L("CVDecTestEngine::TearDown, mem del, iDataChunk") ))
  1.1746 +	#endif
  1.1747 +
  1.1748 +	iDataChunk = NULL;
  1.1749 +
  1.1750 +	iFrameSizeList.Close();
  1.1751 +
  1.1752 +	iInstantFpsList.Close();
  1.1753 +
  1.1754 +	iFs.Close();
  1.1755 +
  1.1756 +	REComSession::FinalClose();
  1.1757 +	PRINT( (_L("CVDecTestEngine::TearDown(), mem allocated: %d "), iMemAlloc))
  1.1758 +	PRINT( (_L("CVDecTestEngine::TearDown(), mem deleted: %d "), iMemDelete))
  1.1759 +	PRINT((_L("CVDecTestEngine::TearDown(),Out")))
  1.1760 +}
  1.1761 +
  1.1762 +
  1.1763 +
  1.1764 +/* ----------------------------------------------------------------------------
  1.1765 +* Name:       CVDecTestEngine::FillAndSendBufferL()
  1.1766 +* Purpose:    Fill data into input buffer and send to devvideoplay
  1.1767 +* Note:
  1.1768 +* Parameters: None
  1.1769 +* Return:     None
  1.1770 +* --------------------------------------------------------------------------*/
  1.1771 +
  1.1772 +
  1.1773 +void CVDecTestEngine::FillAndSendBufferL()
  1.1774 +{
  1.1775 +	PRINT((_L("CVDecTestEngine::FillAndSendBufferL(), In")))
  1.1776 +	TInt err = KErrNone;
  1.1777 +
  1.1778 +	if ( iInputEnd)
  1.1779 +	{
  1.1780 +		iLastFrame = EFalse;
  1.1781 +		//iCodedInBuffer->iOptions =  TVideoInputBuffer::EDecodingTimestamp;
  1.1782 +		//iCodedInBuffer->iDecodingTimestamp = iSentBuffCount+2;
  1.1783 +		//ReadOneCodedPicture(iCodedInBuffer, 0); // Read compressed data of one picture from file
  1.1784 +		//iDevvp->WriteCodedDataL(iCodedInBuffer);  // Input Data Sent to Decoder
  1.1785 +		if (!iDisableInputEnd)
  1.1786 +		{
  1.1787 +			iDevvp->InputEnd();
  1.1788 +			PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Input End")))
  1.1789 +		}
  1.1790 +		else
  1.1791 +		{
  1.1792 +			MdvpoStreamEnd();
  1.1793 +			PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Stream end")))
  1.1794 +		}
  1.1795 +		return;
  1.1796 +	}
  1.1797 +
  1.1798 +	if ( iDecHWDevId )
  1.1799 +	{
  1.1800 +		PRINT((_L("CVDecTestEngine::FillAndSendBufferL(), iDecHWDevID found")))
  1.1801 +		if (  iFrameSizeList.Count() > 0 )
  1.1802 +		{
  1.1803 +			if (iFrameSizeList.Count() <= iSentBuffCount+1)
  1.1804 +			{
  1.1805 +				iInputEnd = ETrue;
  1.1806 +			}
  1.1807 +			TInt size = iFrameSizeList[iSentBuffCount];
  1.1808 +			err = ReadOneCodedPicture(iCodedInBuffer, size); // Read compressed data of one picture from file
  1.1809 +
  1.1810 +			PRINT((_L("CVDecTestEngine::FillAndSendBufferL(), 1 picture read")))
  1.1811 +
  1.1812 +			if( iFrameDropMarker )
  1.1813 +			{
  1.1814 +				if( iFrameDropCounter >= iFrameDropInterval )
  1.1815 +				{
  1.1816 +					TInt dropNum = 0;
  1.1817 +					for( ; ;)
  1.1818 +					{
  1.1819 +						TInt size = iFrameSizeList[iSentBuffCount++];
  1.1820 +						err = ReadOneCodedPicture(iCodedInBuffer, size); // Read compressed data of one picture from file
  1.1821 +						dropNum++;
  1.1822 +						iFrameDropNumCounter++;
  1.1823 +						if( iFrameDropNumCounter >= iFrameDropNum )
  1.1824 +						{
  1.1825 +							iFrameDropCounter = 0;
  1.1826 +							iFrameDropNumCounter = 0;
  1.1827 +							break;
  1.1828 +						}
  1.1829 +					}
  1.1830 +					PRINT((_L("CVDecTestEngine::FillAndSendBufferL(), [%d] frame(s) dropped"), dropNum))
  1.1831 +				}
  1.1832 +			}
  1.1833 +
  1.1834 +
  1.1835 +		}
  1.1836 +		else
  1.1837 +		{
  1.1838 +			err = ReadOneCodedPicture(iCodedInBuffer); // Read compressed data of one picture from file
  1.1839 +			PRINT((_L("CVDecTestEngine::FillAndSendBufferL(), one picture read, err: [%d]"), err))
  1.1840 +
  1.1841 +			if( iFrameDropMarker )
  1.1842 +			{
  1.1843 +				if( iFrameDropCounter >= iFrameDropInterval )
  1.1844 +				{
  1.1845 +					TInt dropNum  = 0;
  1.1846 +					for( ; ;)
  1.1847 +					{
  1.1848 +						err = ReadOneCodedPicture(iCodedInBuffer);
  1.1849 +						dropNum++;
  1.1850 +						iFrameDropNumCounter++;
  1.1851 +						if( iFrameDropNumCounter >= iFrameDropNum )
  1.1852 +						{
  1.1853 +							iFrameDropCounter = 0;
  1.1854 +							iFrameDropNumCounter = 0;
  1.1855 +							break;
  1.1856 +						}
  1.1857 +					}
  1.1858 +					PRINT((_L("CVDecTestEngine::FillAndSendBufferL(), [%d] frame(s) dropped"), dropNum))
  1.1859 +				}
  1.1860 +			}
  1.1861 +
  1.1862 +
  1.1863 +		}
  1.1864 +	}
  1.1865 +	else  // Postproc input case
  1.1866 +	{
  1.1867 +		PRINT((_L("CVDecTestEngine::FillAndSendBufferL(), iDecHWDevID not found")))
  1.1868 +		err = ReadRawPicture();	// Read raw data for one picture
  1.1869 +		if( iFrameDropMarker )
  1.1870 +		{
  1.1871 +			if( iFrameDropCounter >= iFrameDropInterval )
  1.1872 +			{
  1.1873 +				TInt dropNum = 0;
  1.1874 +				for( ; ;)
  1.1875 +				{
  1.1876 +					err = ReadRawPicture();	// Read raw data for one picture
  1.1877 +					dropNum++;
  1.1878 +					iFrameDropNumCounter++;
  1.1879 +					if( iFrameDropNumCounter >= iFrameDropNum )
  1.1880 +					{
  1.1881 +						iFrameDropCounter = 0;
  1.1882 +						iFrameDropNumCounter = 0;
  1.1883 +						break;
  1.1884 +					}
  1.1885 +				}
  1.1886 +				PRINT((_L("CVDecTestEngine::FillAndSendBufferL(), [%d] raw picture(s) dropped"), dropNum))
  1.1887 +			}
  1.1888 +		}
  1.1889 +	}
  1.1890 +	if(err == 0){
  1.1891 +		PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Empty buffer read skipping")))
  1.1892 +		PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Out")))
  1.1893 +	}
  1.1894 +	else if ( err > 0 )
  1.1895 +	{
  1.1896 +		// Corrupt the input if user requires
  1.1897 +		/*
  1.1898 +		if( iCorruptMarker )
  1.1899 +		{
  1.1900 +
  1.1901 +		CorruptEngineL();
  1.1902 +
  1.1903 +		}
  1.1904 +		*/
  1.1905 +		// End of the corrupting operation
  1.1906 +
  1.1907 +		if ( iDecHWDevId )
  1.1908 +		{
  1.1909 +
  1.1910 +			iCodedInBuffer->iOptions =  TVideoInputBuffer::EDecodingTimestamp;
  1.1911 +
  1.1912 +			if ( iPostProcId )
  1.1913 +			{
  1.1914 +				iCodedInBuffer->iOptions |= TVideoInputBuffer::EPresentationTimestamp;
  1.1915 +			}
  1.1916 +
  1.1917 +
  1.1918 +
  1.1919 +			if ( iSynchronized ) // Clock source is set >> real-time synchronization
  1.1920 +			{
  1.1921 +				iCodedInBuffer->iDecodingTimestamp = iTimeStamp;
  1.1922 +				if ( iPostProcId )
  1.1923 +				{
  1.1924 +					iCodedInBuffer->iPresentationTimestamp = iTimeStamp;
  1.1925 +				}
  1.1926 +
  1.1927 +
  1.1928 +				PRINT((_L("CVDecTestEngine::FillAndSendBufferL, iTimestamp added:[%ld]"),iTimeStamp))
  1.1929 +				iTimeStamp += iFrameTimeInterval;
  1.1930 +			}
  1.1931 +			else // Clock source is not set
  1.1932 +			{
  1.1933 +				iCodedInBuffer->iDecodingTimestamp = iSentBuffCount;
  1.1934 +				if ( iPostProcId )
  1.1935 +				{
  1.1936 +					iCodedInBuffer->iPresentationTimestamp = iSentBuffCount;
  1.1937 +				}
  1.1938 +
  1.1939 +			}
  1.1940 +
  1.1941 +			TInt substreamID = 0;
  1.1942 +			//      	    iCodedInBuffer->iUser = (TAny*)(&substreamID);
  1.1943 +			if(iCodedInBuffer->iUser != NULL ){
  1.1944 +				*((TInt*)iCodedInBuffer->iUser) = substreamID;
  1.1945 +			}
  1.1946 +			#if 0
  1.1947 +			TUint32 msgSize = iCodedInBuffer->iData.Length();
  1.1948 +			TUint8* tmpPtr = const_cast<TUint8 *>(iCodedInBuffer->iData.Ptr());
  1.1949 +			while(msgSize > 0)
  1.1950 +			{
  1.1951 +				if(msgSize >= 16)
  1.1952 +				{
  1.1953 +					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]))
  1.1954 +					msgSize -= 16;
  1.1955 +					tmpPtr += 16;
  1.1956 +				}
  1.1957 +				else if(msgSize >= 4)
  1.1958 +				{
  1.1959 +					PRINT((_L("TX:%02x,%02x,%02x,%02x"),tmpPtr[0],tmpPtr[1],tmpPtr[2],tmpPtr[3]))
  1.1960 +					msgSize -= 4;
  1.1961 +					tmpPtr += 4;
  1.1962 +				}
  1.1963 +				else
  1.1964 +				{
  1.1965 +					for(TUint i = 0; i < msgSize; i++)
  1.1966 +					{
  1.1967 +						PRINT((_L("TX: 0x%02x"),*tmpPtr++))
  1.1968 +					}
  1.1969 +					msgSize = 0;
  1.1970 +				}
  1.1971 +			}
  1.1972 +			#endif
  1.1973 +
  1.1974 +			iDevvp->WriteCodedDataL(iCodedInBuffer);  // Input Data Sent to Decoder
  1.1975 +		    iCodedInBuffer = NULL;
  1.1976 +		}
  1.1977 +		else
  1.1978 +		{
  1.1979 +
  1.1980 +			iRawInBuffer->iData.iDataSize.SetSize(iPictureSize.iWidth,iPictureSize.iHeight);
  1.1981 +
  1.1982 +			iRawInBuffer->iOptions |= (TVideoPicture::ETimestamp);
  1.1983 +
  1.1984 +			if ( iSynchronized )
  1.1985 +			{
  1.1986 +				//TTimeIntervalMicroSeconds tsValue(iTimeStamp);
  1.1987 +				iRawInBuffer->iTimestamp = iTimeStamp;
  1.1988 +				iTimeStamp += iFrameTimeInterval;
  1.1989 +				PRINT((_L("CVDecTestEngine::FillAndSendBufferL, iTimestamp added:[%ld]"),iTimeStamp))
  1.1990 +			}
  1.1991 +			else
  1.1992 +			{
  1.1993 +				iRawInBuffer->iTimestamp = iSentBuffCount;
  1.1994 +			}
  1.1995 +
  1.1996 +
  1.1997 +			PRINT((_L("CVDecTestEngine::FillAndSendBufferL, data size: w[%d] ,h[%d]"),iRawInBuffer->iData.iDataSize.iWidth, iRawInBuffer->iData.iDataSize.iHeight))
  1.1998 +			iDevvp->WritePictureL(iRawInBuffer);  // Input Data Sent to PostProcessor
  1.1999 +
  1.2000 +
  1.2001 +			if (iCIBuffMgmtOn)
  1.2002 +			{
  1.2003 +				iRawInBuffer = NULL;
  1.2004 +			}
  1.2005 +
  1.2006 +		}
  1.2007 +
  1.2008 +		iFrameDropCounter++;
  1.2009 +		iSentBuffCount++;
  1.2010 +		PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Sent Frame: [%d] "),iSentBuffCount))
  1.2011 +
  1.2012 +	}
  1.2013 +	else  //Error case
  1.2014 +	{
  1.2015 +		iError = err;
  1.2016 +		PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Error in reading data: [%d] "),iError))
  1.2017 +		iInputEnd = ETrue;
  1.2018 +		iDevvp->InputEnd();
  1.2019 +		return;
  1.2020 +	}
  1.2021 +
  1.2022 +	// if ( iFrameMeasurement )
  1.2023 +	//    return;
  1.2024 +
  1.2025 +	if (iInputEnd)
  1.2026 +	{
  1.2027 +		iLastFrame = ETrue;
  1.2028 +		PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Input end: sending last frame 0 ")))
  1.2029 +		iDecTestAO->RequestData(); // Next Input Data for Decoder / PostProc
  1.2030 +		return;
  1.2031 +	}
  1.2032 +
  1.2033 +	if ( iState == ERunning )
  1.2034 +	{
  1.2035 +		if ( iDecHWDevId )
  1.2036 +		{
  1.2037 +			if (iSetFastClient)
  1.2038 +			{
  1.2039 +				PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Fast client request")))
  1.2040 +				iDecTestAO->RequestData(); // Next Input Data for Decoder / PostProc
  1.2041 +			}
  1.2042 +			else
  1.2043 +			{
  1.2044 +				if ( iDevvp->NumFreeBuffers() )
  1.2045 +				{
  1.2046 +					iDecTestAO->RequestData(); // Next Input Data for Decoder / PostProc
  1.2047 +				}
  1.2048 +				else
  1.2049 +				{
  1.2050 +					PRINT((_L("CVDecTestEngine::FillAndSendBufferL, No input buffer available now")))
  1.2051 +					iNoBuffAvailable++;
  1.2052 +				}
  1.2053 +			}
  1.2054 +		}
  1.2055 +	}
  1.2056 +
  1.2057 +
  1.2058 +	PRINT((_L("CVDecTestEngine::FillAndSendBufferL, Out")))
  1.2059 +
  1.2060 +}
  1.2061 +
  1.2062 +
  1.2063 +/* ----------------------------------------------------------------------------
  1.2064 +* Name:       CVDecTestEngine::GetInputBufferL()
  1.2065 +* Purpose:    Ritreave decoder input buffer
  1.2066 +* Note:
  1.2067 +* Parameters: None
  1.2068 +* Return:     None
  1.2069 +* --------------------------------------------------------------------------*/
  1.2070 +
  1.2071 +
  1.2072 +void CVDecTestEngine::GetInputBufferL()
  1.2073 +{
  1.2074 +	TBool buffer = EFalse;
  1.2075 +
  1.2076 +	if ( iState == ERunning )
  1.2077 +	{
  1.2078 +		if ( iDecHWDevId )
  1.2079 +		{
  1.2080 +			iCodedInBuffer = iDevvp->GetBufferL(iInBuffSize);
  1.2081 +			if ( iCodedInBuffer )
  1.2082 +			{
  1.2083 +				buffer = ETrue;
  1.2084 +			}
  1.2085 +
  1.2086 +		}
  1.2087 +		else if ( iCIBuffMgmtOn )
  1.2088 +		{
  1.2089 +			PRINT((_L("CVDecTestEngine::GetInputBufferL(), Getting Input buffer(CI)...")))
  1.2090 +			#ifdef __CI_HEADERS__
  1.2091 +			TVideoPicture* inputBuff = iCIBuffMgmt->MmvbmGetBufferL(iPictureSize);
  1.2092 +			if ( inputBuff )
  1.2093 +			{
  1.2094 +				buffer = ETrue;
  1.2095 +				iRawInBuffer = inputBuff;
  1.2096 +			}
  1.2097 +			#endif
  1.2098 +		}
  1.2099 +	}
  1.2100 +
  1.2101 +	if ( buffer )
  1.2102 +	{
  1.2103 +		PRINT((_L("CVDecTestEngine::GetInputBufferL(), Got Input buffer")))
  1.2104 +		FillAndSendBufferL();
  1.2105 +	}
  1.2106 +	else
  1.2107 +	{
  1.2108 +		PRINT((_L("CVDecTestEngine::GetInputBufferL(), Couldn't get input buffer ")))
  1.2109 +	}
  1.2110 +
  1.2111 +}
  1.2112 +
  1.2113 +
  1.2114 +
  1.2115 +/* ----------------------------------------------------------------------------
  1.2116 +* Name:       CVDecTestEngine::ReadOneCodedPicture()
  1.2117 +* Purpose:    Read one coded picture into decoder input buffer
  1.2118 +* Note:
  1.2119 +* Parameters: TVideoInputBuffer* aCodedInBuffer
  1.2120 +* Return:     TInt
  1.2121 +* --------------------------------------------------------------------------*/
  1.2122 +TInt CVDecTestEngine::ReadOneCodedPicture(TVideoInputBuffer* aCodedInBuffer)
  1.2123 +{
  1.2124 +	PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, In")))
  1.2125 +	TInt buffLength = iInBuffSize;
  1.2126 +	TBool found = EFalse;
  1.2127 +	TInt pos =0;
  1.2128 +	TUint8* testData =NULL;
  1.2129 +	TInt err = KErrNone;
  1.2130 +
  1.2131 +	//Reads VC1 frame
  1.2132 +	if ( iCodecType == EVC1 )
  1.2133 +	{
  1.2134 +		PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, VC1")))
  1.2135 +		return LoadNextFrameL(aCodedInBuffer);
  1.2136 +	}
  1.2137 +
  1.2138 +	if ( aCodedInBuffer->iData.MaxLength() < buffLength )
  1.2139 +	{
  1.2140 +		err = KErrOverflow;
  1.2141 +		PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Buffer is small, [%d]Byte"),aCodedInBuffer->iData.MaxLength()))
  1.2142 +
  1.2143 +		return err;
  1.2144 +	}
  1.2145 +
  1.2146 +	aCodedInBuffer->iData.SetLength(0);
  1.2147 +
  1.2148 +	//Buffer is not full,  reset size of buffer
  1.2149 +	if ( aCodedInBuffer->iData.Length() < buffLength)
  1.2150 +	{
  1.2151 +		buffLength = aCodedInBuffer->iData.Length();
  1.2152 +	}
  1.2153 +
  1.2154 +	testData = const_cast<TUint8*>(aCodedInBuffer->iData.Ptr());
  1.2155 +
  1.2156 +	TUint8* iReadDataChunkTemp = iReadDataChunk;
  1.2157 +
  1.2158 +	TUint8 byte = 0;
  1.2159 +
  1.2160 +	//Check the length of one coded picture
  1.2161 +	if (iCodecType == EH263)
  1.2162 +	{
  1.2163 +		TBool firstStartCode = EFalse;
  1.2164 +		while (!iInputEnd && !found)
  1.2165 +		{
  1.2166 +			TInt zeroCounter = 0;
  1.2167 +			while ((byte = ReadByteFromFile()) == 0x00 && !iInputEnd)
  1.2168 +			{
  1.2169 +				zeroCounter++;
  1.2170 +				pos++;
  1.2171 +			}
  1.2172 +			pos++;
  1.2173 +			if ((zeroCounter >= 2) && ((byte & 0xFC) == 0x80))
  1.2174 +			{
  1.2175 +				if (!firstStartCode)
  1.2176 +				{
  1.2177 +					firstStartCode = ETrue;
  1.2178 +				}
  1.2179 +				else
  1.2180 +				{
  1.2181 +					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, end of h263 picture found")))
  1.2182 +					found = ETrue;
  1.2183 +				}
  1.2184 +			}
  1.2185 +		}
  1.2186 +		if (iInputEnd)
  1.2187 +		{
  1.2188 +			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, inputEndFound, %d"), pos))
  1.2189 +			pos--;
  1.2190 +		}
  1.2191 +		else
  1.2192 +		{
  1.2193 +			pos -= KScLength;
  1.2194 +		}
  1.2195 +		iReadDataChunk = iReadDataChunkTemp;
  1.2196 +		ReadDataToBuffer(aCodedInBuffer, pos);
  1.2197 +
  1.2198 +	}
  1.2199 +	else if ( iCodecType == EMPEG4 )
  1.2200 +	{
  1.2201 +		TBool firstStartCode = EFalse;
  1.2202 +		while (!iInputEnd && !found)
  1.2203 +		{
  1.2204 +			TInt zeroCounter = 0;
  1.2205 +			while ((byte = ReadByteFromFile()) == 0x00 && !iInputEnd)
  1.2206 +			{
  1.2207 +				zeroCounter++;
  1.2208 +				pos++;
  1.2209 +			}
  1.2210 +			pos++;
  1.2211 +			if ((zeroCounter >= 2) && (byte == 0x01))
  1.2212 +			{
  1.2213 +				byte = ReadByteFromFile();
  1.2214 +
  1.2215 +				pos++;
  1.2216 +				if (byte == 0xB6 && !firstStartCode)
  1.2217 +				{
  1.2218 +					firstStartCode = ETrue;
  1.2219 +				}
  1.2220 +				else if (byte != 0xB1 && firstStartCode)
  1.2221 +				{
  1.2222 +					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, end of mpeg-4 picture found [%d]"), pos-4))
  1.2223 +					found = ETrue;
  1.2224 +				}
  1.2225 +			}
  1.2226 +		}
  1.2227 +		if (iInputEnd)
  1.2228 +		{
  1.2229 +			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, inputEndFound, %d"), pos))
  1.2230 +			pos--;
  1.2231 +		}
  1.2232 +		else
  1.2233 +		{
  1.2234 +			pos -= 4;
  1.2235 +		}
  1.2236 +		iReadDataChunk = iReadDataChunkTemp;
  1.2237 +		ReadDataToBuffer(aCodedInBuffer, pos);
  1.2238 +	}
  1.2239 +	else if ( iCodecType == EVP6 )
  1.2240 +	{
  1.2241 +		TUint dataCount = 0;
  1.2242 +		if (iSentBuffCount == 0)
  1.2243 +		{
  1.2244 +			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, First VP6 frame")))
  1.2245 +			//Read signature and version
  1.2246 +			for (TUint i=0; i<5; i++)
  1.2247 +			{
  1.2248 +				byte = ReadByteFromFile();
  1.2249 +			}
  1.2250 +			TUint32 offset = (TUint32)(ReadByteFromFile())<< 24 | (TUint32)(ReadByteFromFile())<< 16 |
  1.2251 +			(TUint32)(ReadByteFromFile())<< 8 | (TUint32)(ReadByteFromFile());
  1.2252 +
  1.2253 +			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, offset %d"), offset))
  1.2254 +			//Jump data after offset
  1.2255 +			for (TUint i=0; i< offset-9; i++ )
  1.2256 +			{
  1.2257 +				byte = ReadByteFromFile();
  1.2258 +			}
  1.2259 +			dataCount += 9+offset-9;
  1.2260 +			//Read previous tag size
  1.2261 +			for (TUint i=0; i< 4; i++ )
  1.2262 +			{
  1.2263 +				byte = ReadByteFromFile();
  1.2264 +			}
  1.2265 +
  1.2266 +		}
  1.2267 +		if (!iInputEnd)
  1.2268 +		{
  1.2269 +
  1.2270 +			TUint8 tagType = ReadByteFromFile();
  1.2271 +
  1.2272 +			if (!iInputEnd)
  1.2273 +			{
  1.2274 +
  1.2275 +				PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, tagType %d"), tagType))
  1.2276 +				dataCount += 5;
  1.2277 +				while (tagType != 9 && !iInputEnd)
  1.2278 +				{
  1.2279 +					TUint32 a = (TUint32)(ReadByteFromFile());
  1.2280 +					TUint32 b = (TUint32)(ReadByteFromFile());
  1.2281 +					TUint32 c = (TUint32)(ReadByteFromFile());
  1.2282 +					TUint32 dataSize =  (a << 16) | (b << 8) | (c);
  1.2283 +					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, dataSize %d"), dataSize))
  1.2284 +					ReadDataToBuffer(aCodedInBuffer, dataSize+7, ETrue);
  1.2285 +					//Previous offset
  1.2286 +					for (TUint i=0; i< 4; i++ )
  1.2287 +					{
  1.2288 +						byte = ReadByteFromFile();
  1.2289 +					}
  1.2290 +					tagType = ReadByteFromFile();
  1.2291 +					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, tagType %d"), tagType))
  1.2292 +					dataCount += dataSize+15;
  1.2293 +				}
  1.2294 +				if(!iInputEnd){
  1.2295 +				TUint32 a = (TUint32)(ReadByteFromFile());
  1.2296 +				TUint32 b = (TUint32)(ReadByteFromFile());
  1.2297 +				TUint32 c = (TUint32)(ReadByteFromFile());
  1.2298 +				TUint32 dataSize =  (a << 16) | (b << 8) | (c);
  1.2299 +				//Discard timestamp and streamID
  1.2300 +				for (TUint i=0; i< 7; i++ )
  1.2301 +				{
  1.2302 +					byte = ReadByteFromFile();
  1.2303 +				}
  1.2304 +				//Frametype and codec ID
  1.2305 +				byte = ReadByteFromFile();
  1.2306 +				//Read VP6 frame to buffer
  1.2307 +				ReadDataToBuffer(aCodedInBuffer, dataSize-1);
  1.2308 +				PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, VP6 frame size %d"), dataSize))
  1.2309 +				dataCount += dataSize+10;
  1.2310 +				//Read previous tag size
  1.2311 +				for (TUint i=0; i< 4; i++ )
  1.2312 +				{
  1.2313 +					byte = ReadByteFromFile();
  1.2314 +				}
  1.2315 +				}
  1.2316 +				else{
  1.2317 +				PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, unknown tags at the end of vp6 stream, discard")))
  1.2318 +				dataCount = 0;
  1.2319 +				}
  1.2320 +			}
  1.2321 +		}
  1.2322 +		if (iInputEnd)
  1.2323 +		{
  1.2324 +			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, inputEndFound")))
  1.2325 +			//aCodedInBuffer.iData->Zero();
  1.2326 +		}
  1.2327 +		return dataCount;
  1.2328 +	}
  1.2329 +	else if ( iCodecType == EFLV )
  1.2330 +	{
  1.2331 +		// FLV fileformat has 3 first bytes 'FLV'. Detect if file has container.
  1.2332 +		PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, find out bitstream type %d == %d."),iFLVFileType,EFLVNotSet));
  1.2333 +
  1.2334 +
  1.2335 +		if(iFLVFileType == EFLVNotSet)
  1.2336 +		{
  1.2337 +			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, find out bitstream type.")));
  1.2338 +
  1.2339 +			byte = ReadByteFromFile();
  1.2340 +			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, %02x"),byte));
  1.2341 +			TUint8 byte2 = ReadByteFromFile();
  1.2342 +			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, %02x"),byte2));
  1.2343 +			TUint8 byte3 = ReadByteFromFile();
  1.2344 +			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, %02x"),byte3));
  1.2345 +			if ( (byte == 0x46) && (byte2 == 0x4C) && (byte3 == 0x56) )
  1.2346 +			{
  1.2347 +				PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, file with container detected.")));
  1.2348 +				iFLVFileType = EFLVContainer;
  1.2349 +			}
  1.2350 +			else
  1.2351 +			{
  1.2352 +				PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, file raw bitstream detected.")));
  1.2353 +				iFLVFileType = EFLVRaw;
  1.2354 +			}
  1.2355 +			iReadDataChunk = iReadDataChunkTemp;
  1.2356 +		}
  1.2357 +
  1.2358 +		if (iFLVFileType == EFLVContainer)
  1.2359 +		{
  1.2360 +			// FLV frames have 00 00 x2 00 00 8x startcode, parse it.
  1.2361 +			TBool firstStartCode = EFalse;
  1.2362 +			TBool frameHeaderEnd = EFalse;
  1.2363 +			TBool frameHeader = EFalse;
  1.2364 +			while (!iInputEnd && !found)
  1.2365 +			{
  1.2366 +				TInt zeroCounter = 0;
  1.2367 +				while ((byte = ReadByteFromFile()) == 0x00 && !iInputEnd)
  1.2368 +				{
  1.2369 +					zeroCounter++;
  1.2370 +					pos++;
  1.2371 +				}
  1.2372 +				pos++;
  1.2373 +				if ((zeroCounter >= 2) && ((byte & 0xF8) == 0x80) && frameHeaderEnd)
  1.2374 +				{
  1.2375 +					// FLV frames have some bytes in the beginning which needs to be removed
  1.2376 +					if (!frameHeader)
  1.2377 +					{
  1.2378 +						iReadDataChunk = iReadDataChunkTemp;
  1.2379 +						ReadDataToBuffer(aCodedInBuffer, pos-3);
  1.2380 +
  1.2381 +						PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, [%d] bytes of flash video frame header removed."), (iReadDataChunk - iReadDataChunkTemp)));
  1.2382 +						iReadDataChunkTemp = iReadDataChunk;
  1.2383 +						zeroCounter = 0;
  1.2384 +						pos = 0;
  1.2385 +						frameHeader = ETrue;
  1.2386 +					}
  1.2387 +					else if (!firstStartCode)
  1.2388 +					{
  1.2389 +						firstStartCode = ETrue;
  1.2390 +						PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, start of flash video picture found [%d]."), pos-3))
  1.2391 +
  1.2392 +					}
  1.2393 +					else
  1.2394 +					{
  1.2395 +						PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, end of flash video picture found [%d]"), pos-3))
  1.2396 +						found = ETrue;
  1.2397 +					}
  1.2398 +				}
  1.2399 +				else if ((zeroCounter >= 2) && ((byte & 0x03) == 0x02))
  1.2400 +				{
  1.2401 +					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, found frame end code at [%d]"), pos-3))
  1.2402 +
  1.2403 +					frameHeaderEnd = ETrue;
  1.2404 +				}
  1.2405 +				else
  1.2406 +				{
  1.2407 +					frameHeaderEnd = EFalse;
  1.2408 +				}
  1.2409 +			}
  1.2410 +			if (iInputEnd)
  1.2411 +			{
  1.2412 +				PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, inputEndFound, %d"), pos))
  1.2413 +				pos--;
  1.2414 +
  1.2415 +				// FLV file has four bytes which needs to be removed in the end
  1.2416 +				pos -= 4;
  1.2417 +			}
  1.2418 +			else
  1.2419 +			{
  1.2420 +				// Go back to beginning of start code (3 bytes)
  1.2421 +				pos -= 3;
  1.2422 +				// Go back to beginning of FLV file frame header(16 bytes)
  1.2423 +				pos -= 16;
  1.2424 +			}
  1.2425 +			iReadDataChunk = iReadDataChunkTemp;
  1.2426 +			ReadDataToBuffer(aCodedInBuffer, pos);
  1.2427 +		}
  1.2428 +		// Raw flash bitstream file
  1.2429 +		else
  1.2430 +		{
  1.2431 +			TBool firstStartCode = EFalse;
  1.2432 +			while (!iInputEnd && !found)
  1.2433 +			{
  1.2434 +				TInt zeroCounter = 0;
  1.2435 +				while ((byte = ReadByteFromFile()) == 0x00 && !iInputEnd)
  1.2436 +				{
  1.2437 +					zeroCounter++;
  1.2438 +					pos++;
  1.2439 +				}
  1.2440 +				pos++;
  1.2441 +				if ((zeroCounter >= 2) && ((byte & 0xF8) == 0x80))
  1.2442 +				{
  1.2443 +					if (!firstStartCode)
  1.2444 +					{
  1.2445 +						firstStartCode = ETrue;
  1.2446 +					}
  1.2447 +					else
  1.2448 +					{
  1.2449 +						PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, end of flash video picture found [%d]"), pos-3))
  1.2450 +
  1.2451 +						found = ETrue;
  1.2452 +					}
  1.2453 +				}
  1.2454 +			}
  1.2455 +			if (iInputEnd)
  1.2456 +			{
  1.2457 +				PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, inputEndFound, %d"), pos))
  1.2458 +				pos--;
  1.2459 +			}
  1.2460 +			else
  1.2461 +			{
  1.2462 +				pos -= 3;
  1.2463 +			}
  1.2464 +			iReadDataChunk = iReadDataChunkTemp;
  1.2465 +			ReadDataToBuffer(aCodedInBuffer, pos);
  1.2466 +		}
  1.2467 +	}
  1.2468 +	else if ( iCodecType == EAVC )
  1.2469 +	{
  1.2470 +		if (iSetAUFormat)
  1.2471 +		{
  1.2472 +			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, AU format case")))
  1.2473 +			TBool auFound = EFalse;
  1.2474 +			TBool firstMB = EFalse;
  1.2475 +			TUint32 nalUnits = 0;
  1.2476 +			TUint32 totalData = 0;
  1.2477 +			iNalOffsetArray = new TUint32[KMaxNumberOfNals];
  1.2478 +			iNalLengthArray = new TUint32[KMaxNumberOfNals];
  1.2479 +			iMemAlloc += 2;
  1.2480 +			TInt previousNal = 0;
  1.2481 +			while (!auFound)
  1.2482 +			{
  1.2483 +				TBool firstStartCode = EFalse;
  1.2484 +				// Check if start code of Visual Object Sequence
  1.2485 +				pos = 0;
  1.2486 +				TInt nalStart = 0;
  1.2487 +				while (!iInputEnd && !found && !auFound)
  1.2488 +				{
  1.2489 +					TInt zeroCounter = 0;
  1.2490 +					while ((byte = ReadByteFromFile()) == 0x00 && !iInputEnd)
  1.2491 +					{
  1.2492 +						zeroCounter++;
  1.2493 +						pos++;
  1.2494 +					}
  1.2495 +					pos++;
  1.2496 +					if ((zeroCounter >= 2) && (byte  == 0x01))
  1.2497 +					{
  1.2498 +						if (!firstStartCode)
  1.2499 +						{
  1.2500 +							firstStartCode = ETrue;
  1.2501 +							nalStart = pos - KScLength;
  1.2502 +							iNalOffsetArray[nalUnits] = pos+totalData;
  1.2503 +
  1.2504 +							byte = ReadByteFromFile();
  1.2505 +							pos++;
  1.2506 +
  1.2507 +							if (((byte & 0x1F) == 7) && ( previousNal == 5 || previousNal == 1 ) )
  1.2508 +							{
  1.2509 +								auFound = ETrue;
  1.2510 +								pos -= 4;
  1.2511 +								GoBackInFile(4);
  1.2512 +							}
  1.2513 +							else if (((byte & 0x1F) == 5) || ((byte & 0x1F) == 1))
  1.2514 +							{
  1.2515 +								byte = ReadByteFromFile();
  1.2516 +								pos++;
  1.2517 +								if (byte >= 128)
  1.2518 +								{
  1.2519 +									if (firstMB)
  1.2520 +									{
  1.2521 +										//NAL that belongs to the next AU
  1.2522 +										PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Next AU Nal Found")))
  1.2523 +										auFound = ETrue;
  1.2524 +										pos -= 5;
  1.2525 +										GoBackInFile(5);
  1.2526 +									}
  1.2527 +									else
  1.2528 +									{
  1.2529 +										PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, First MB")))
  1.2530 +										firstMB = ETrue;
  1.2531 +									}
  1.2532 +								}
  1.2533 +							}
  1.2534 +							previousNal = byte & 0x1F;
  1.2535 +
  1.2536 +						}
  1.2537 +						else
  1.2538 +						{
  1.2539 +							PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, NAL start: [%d]"), nalStart ))
  1.2540 +							PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, end of h264 NAL found at [%d]"), pos ))
  1.2541 +
  1.2542 +							found = ETrue;
  1.2543 +							pos -= KScLength;
  1.2544 +							GoBackInFile(KScLength); //go back before next start code
  1.2545 +						}
  1.2546 +					}
  1.2547 +				}
  1.2548 +
  1.2549 +				if (!found && iInputEnd)
  1.2550 +				{
  1.2551 +					auFound = ETrue;
  1.2552 +					if ( nalUnits == 0 )
  1.2553 +					{
  1.2554 +						totalData = pos;
  1.2555 +						PRINT((_L("CVDecTestEngine::ReadOneCodedPicture: pos: %d"),pos))
  1.2556 +						iNalLengthArray[nalUnits] = pos;
  1.2557 +						nalUnits++;
  1.2558 +					}
  1.2559 +				}
  1.2560 +				found = EFalse;
  1.2561 +				if (!auFound)
  1.2562 +				{
  1.2563 +					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Searching next NAL")))
  1.2564 +					totalData += pos;
  1.2565 +					iNalLengthArray[nalUnits] = pos - 3 - nalStart;
  1.2566 +					nalUnits++;
  1.2567 +				}
  1.2568 +				else
  1.2569 +				{
  1.2570 +					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, AU Found")))
  1.2571 +					iReadDataChunk = iReadDataChunkTemp;
  1.2572 +					ReadDataToBuffer(aCodedInBuffer, totalData);
  1.2573 +					pos = totalData; //Set amount of data read from a file
  1.2574 +					//Optional filler data to align the header at a 32-bit boundary
  1.2575 +					while ((totalData % 4) != 0)
  1.2576 +					{
  1.2577 +						testData[totalData] = 0;
  1.2578 +						totalData++;
  1.2579 +					}
  1.2580 +					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Casting headerpointer")))
  1.2581 +					TUint8* headerData = reinterpret_cast<TUint8*>(const_cast<TUint8*>(aCodedInBuffer->iData.Ptr()));
  1.2582 +					TUint headerStart = totalData; //changing 8bit index to 32bit
  1.2583 +					for (TUint i = 0; i < nalUnits; i++)
  1.2584 +					{
  1.2585 +						*((TUint32*)&headerData[headerStart]) = static_cast<TUint32>(iNalOffsetArray[i]);
  1.2586 +						PRINT((_L("CVDecTestEngine::ReadOneCodedPicture: offset [%d] | [%d] "), iNalOffsetArray[i], headerData[headerStart]))
  1.2587 +						*((TUint32*)&headerData[headerStart+4]) = static_cast<TUint32>(iNalLengthArray[i]);
  1.2588 +						PRINT((_L("CVDecTestEngine::ReadOneCodedPicture: size [%d] | [%d][%d][%d][%d] "), iNalLengthArray[i], headerData[headerStart+4],headerData[headerStart+5],headerData[headerStart+6],headerData[headerStart+7]))
  1.2589 +						headerStart += 8;
  1.2590 +					}
  1.2591 +					*((TUint32*)&headerData[headerStart]) = static_cast<TUint32>(nalUnits);
  1.2592 +					headerStart += 4;
  1.2593 +					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, deleting arrays")))
  1.2594 +					delete iNalLengthArray;
  1.2595 +					iNalLengthArray = NULL;
  1.2596 +					iMemDelete++;
  1.2597 +					delete iNalOffsetArray;
  1.2598 +					iNalOffsetArray = NULL;
  1.2599 +					iMemDelete++;
  1.2600 +					#ifdef __MEM_CHECK_
  1.2601 +					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, mem del, iNalLengthArray") ))
  1.2602 +					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, mem del, iNalOffsetArray") ))
  1.2603 +					#endif
  1.2604 +
  1.2605 +					/*for (TUint i = 0; i < 100; i++)
  1.2606 +					{
  1.2607 +					PRINT((_L("test data End [%d]"), testData[pos-100+i]))
  1.2608 +					} */
  1.2609 +
  1.2610 +					//Set Size to length of the header + one picure, and reset position to be read next time
  1.2611 +					aCodedInBuffer->iData.SetLength(headerStart);
  1.2612 +					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture,length of frame: [%d] "),pos))
  1.2613 +					//TInt tempLength = pos - buffLength;
  1.2614 +					//err = iInFile.Seek(ESeekCurrent,tempLength);
  1.2615 +					return pos;
  1.2616 +				}
  1.2617 +			}
  1.2618 +		}
  1.2619 +		else
  1.2620 +		{
  1.2621 +			PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Bytestream case")))
  1.2622 +			TBool auFound = EFalse;
  1.2623 +			TBool firstMB = EFalse;
  1.2624 +			TUint32 totalData = 0;
  1.2625 +			TInt previousNal = 0;
  1.2626 +			while (!auFound)
  1.2627 +			{
  1.2628 +				// Check if start code of Visual Object Sequence
  1.2629 +				TBool firstStartCode = EFalse;
  1.2630 +				pos = 0;
  1.2631 +				TInt nalStart = 0;
  1.2632 +				while (!iInputEnd && !found)
  1.2633 +				{
  1.2634 +					TInt zeroCounter = 0;
  1.2635 +					while ((byte = ReadByteFromFile()) == 0x00 && !iInputEnd)
  1.2636 +					{
  1.2637 +						zeroCounter++;
  1.2638 +						pos++;
  1.2639 +					}
  1.2640 +					pos++;
  1.2641 +					if ((zeroCounter >= 2) && (byte  == 0x01))
  1.2642 +					{
  1.2643 +						if (!firstStartCode)
  1.2644 +						{
  1.2645 +							firstStartCode = ETrue;
  1.2646 +							nalStart = pos-KScLength;
  1.2647 +							byte = ReadByteFromFile();
  1.2648 +							pos++;
  1.2649 +
  1.2650 +							if (((byte & 0x1F) == 7) && ( previousNal == 5 || previousNal == 1 ) )
  1.2651 +							{
  1.2652 +								auFound = ETrue;
  1.2653 +								pos -= 4;
  1.2654 +								GoBackInFile(4);
  1.2655 +							}
  1.2656 +							else if (((byte & 0x1F) == 5) || ((byte & 0x1F) == 1))
  1.2657 +							{
  1.2658 +								byte = ReadByteFromFile();
  1.2659 +								pos++;
  1.2660 +								if (byte >= 128)
  1.2661 +								{
  1.2662 +									if (firstMB)
  1.2663 +									{
  1.2664 +										//NAL that belongs to the next AU
  1.2665 +										PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Next AU Nal Found")))
  1.2666 +										auFound = ETrue;
  1.2667 +										pos -= 5;
  1.2668 +										GoBackInFile(5);
  1.2669 +									}
  1.2670 +									else
  1.2671 +									{
  1.2672 +										PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, First MB")))
  1.2673 +										firstMB = ETrue;
  1.2674 +									}
  1.2675 +								}
  1.2676 +							}
  1.2677 +							previousNal = byte & 0x1F;
  1.2678 +
  1.2679 +						}
  1.2680 +						else
  1.2681 +						{
  1.2682 +							PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, NAL start: [%d]"), nalStart ))
  1.2683 +							PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, end of h264 NAL found at [%d]"), pos ))
  1.2684 +							found = ETrue;
  1.2685 +							pos -= KScLength;
  1.2686 +							GoBackInFile(KScLength); //go back before next start code
  1.2687 +						}
  1.2688 +					}
  1.2689 +				}
  1.2690 +
  1.2691 +				if (!found && iInputEnd)
  1.2692 +				{
  1.2693 +					totalData += pos;
  1.2694 +					auFound = ETrue;
  1.2695 +				}
  1.2696 +				found = EFalse;
  1.2697 +				if (!auFound)
  1.2698 +				{
  1.2699 +					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Searching next NAL")))
  1.2700 +					totalData += pos;
  1.2701 +				}
  1.2702 +				else
  1.2703 +				{
  1.2704 +					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, AU Found")))
  1.2705 +					iReadDataChunk = iReadDataChunkTemp;
  1.2706 +					ReadDataToBuffer(aCodedInBuffer, totalData);
  1.2707 +					pos = totalData; //Set amount of data read from a file
  1.2708 +					PRINT((_L("CVDecTestEngine::ReadOneCodedPicture,length of frame: [%d] "),pos));
  1.2709 +					return pos;
  1.2710 +				}
  1.2711 +			}
  1.2712 +
  1.2713 +		}
  1.2714 +	}
  1.2715 +	else
  1.2716 +	{
  1.2717 +		err = KErrNotSupported;
  1.2718 +		PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, codec type unknown")))
  1.2719 +	}
  1.2720 +
  1.2721 +	if (err == KErrNone)  // wk45 for listing frame size
  1.2722 +	err = pos;
  1.2723 +
  1.2724 +	PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Out")))
  1.2725 +	return err;
  1.2726 +}
  1.2727 +
  1.2728 +/* ----------------------------------------------------------------------------
  1.2729 +* Name:       CVDecTestEngine::ReadOneCodedPicture()
  1.2730 +* Purpose:    Read one coded picture into decoder input buffer, frame size is known
  1.2731 +* Note:
  1.2732 +* Parameters: TVideoInputBuffer* aCodedInBuffer TInt Size
  1.2733 +* Return:     TInt
  1.2734 +* --------------------------------------------------------------------------*/
  1.2735 +
  1.2736 +TInt CVDecTestEngine::ReadOneCodedPicture(TVideoInputBuffer* aCodedInBuffer, TInt aSize)
  1.2737 +{
  1.2738 +	TInt err = KErrNone;
  1.2739 +
  1.2740 +	err = iInFile.Read(aCodedInBuffer->iData, aSize);
  1.2741 +	PRINT((_L("CVDecTestEngine::ReadOneCodedPicture, Frame Size"),aSize ))
  1.2742 +
  1.2743 +	if (err == KErrNone)
  1.2744 +	{
  1.2745 +		err = aSize;
  1.2746 +	}
  1.2747 +
  1.2748 +	if (aSize == 0)
  1.2749 +	{
  1.2750 +		iInputEnd = ETrue;
  1.2751 +	}
  1.2752 +
  1.2753 +	return err;
  1.2754 +}
  1.2755 +
  1.2756 +
  1.2757 +
  1.2758 +/* ----------------------------------------------------------------------------
  1.2759 +* Name:       CVDecTestEngine::ReadRawPicture()
  1.2760 +* Purpose:    Read one raw picture into postprocessor input buffer
  1.2761 +* Note:
  1.2762 +* Parameters: None
  1.2763 +* Return:     None
  1.2764 +* --------------------------------------------------------------------------*/
  1.2765 +
  1.2766 +
  1.2767 +TInt CVDecTestEngine::ReadRawPicture()
  1.2768 +{
  1.2769 +	TInt err = KErrNone;
  1.2770 +
  1.2771 +	PRINT((_L("CVDecTestEngine::ReadRawPicture, Maximum data length in video picture: [%d]"),iRawInBuffer->iData.iRawData->MaxLength()))
  1.2772 +	iRawInBuffer->iData.iRawData->Set((TUint8*)iRawInBuffer->iData.iRawData->Ptr(), 0, iInBuffSize);
  1.2773 +
  1.2774 +
  1.2775 +	err = iInFile.Read(*(iRawInBuffer->iData.iRawData),iInBuffSize);
  1.2776 +	PRINT((_L("CVDecTestEngine::ReadRawPicture, data length:[%d]"),iRawInBuffer->iData.iRawData->Length()))
  1.2777 +
  1.2778 +	if ( !err )
  1.2779 +	{
  1.2780 +		if ( (iRawInBuffer->iData.iRawData->Length()) == 0)
  1.2781 +		{
  1.2782 +			iInputEnd = ETrue;
  1.2783 +		}
  1.2784 +	}
  1.2785 +
  1.2786 +	PRINT((_L("CVDecTestEngine::ReadRawPicture, Out error:[%d]"),err))
  1.2787 +	return err;
  1.2788 +
  1.2789 +}
  1.2790 +
  1.2791 +/* ----------------------------------------------------------------------------
  1.2792 +* Name:       CVDecTestEngine::GetReturnedPictureL
  1.2793 +* Purpose:    Retrieve output picuture
  1.2794 +* Note:       Memory buffer output is used
  1.2795 +* Parameters: None
  1.2796 +* Return:     None
  1.2797 +* --------------------------------------------------------------------------*/
  1.2798 +
  1.2799 +
  1.2800 +void CVDecTestEngine::GetReturnedPictureL()
  1.2801 +{
  1.2802 +	PRINT((_L("CVDecTestEngine::GetReturnedPictureL, In")))
  1.2803 +	iOutBuffer = iDevvp->NextPictureL();
  1.2804 +
  1.2805 +	if ( iOutBuffer )
  1.2806 +	{
  1.2807 +		PRINT((_L("CVDecTestEngine::GetReturnedPictureL, data Size in Byte:[%d]"),iOutBuffer->iData.iRawData->Size() ))
  1.2808 +		iReturnedBuffCount++;
  1.2809 +		SaveAndReturnPicture();
  1.2810 +	}
  1.2811 +	PRINT((_L("CVDecTestEngine::GetReturnedPictureL, Out")))
  1.2812 +}
  1.2813 +
  1.2814 +
  1.2815 +/* ----------------------------------------------------------------------------
  1.2816 +* Name:       CVDecTestEngine::SaveAndReturnPicture()
  1.2817 +* Purpose:    Store output data into a file
  1.2818 +* Note:       Memory buffer output is used
  1.2819 +* Parameters: None
  1.2820 +* Return:     None
  1.2821 +* --------------------------------------------------------------------------*/
  1.2822 +
  1.2823 +void CVDecTestEngine::SaveAndReturnPicture()
  1.2824 +{
  1.2825 +	PRINT((_L("CVDecTestEngine::SaveAndReturnPicture, In")))
  1.2826 +	TInt err = KErrNone;
  1.2827 +
  1.2828 +	if (iFrameMeasurement && iReturnedBuffCount == 1)
  1.2829 +	{
  1.2830 +		iClock->Reset(); // Reset Timer
  1.2831 +		PRINT((_L("CVDecTestEngine::SaveAndReturnPicture, clock reset")))
  1.2832 +	}
  1.2833 +	else
  1.2834 +	{
  1.2835 +		if ( iFrameMeasurement )
  1.2836 +		{
  1.2837 +			PRINT((_L("CVDecTestEngine::SaveAndReturnPicture, Frame measurement is on, %d. frame"), iReturnedBuffCount))
  1.2838 +			TTimeIntervalMicroSeconds time;
  1.2839 +			time = iClock->Time();
  1.2840 +			PRINT((_L("CVDecTestEngine::SaveAndReturnPicture, time measured: [%d%d]"), I64HIGH(time.Int64()), I64LOW(time.Int64())))
  1.2841 +			iFrameTime = (TReal)time.Int64()/1000000.0;
  1.2842 +			if(iInstantFpsEnabled)
  1.2843 +			{
  1.2844 +				iInstantFpsList.Append(time);
  1.2845 +			}
  1.2846 +
  1.2847 +		}
  1.2848 +		else
  1.2849 +		{
  1.2850 +			err = iOutFile.Write(*(iOutBuffer->iData.iRawData),iOutBuffer->iData.iRawData->Size() );
  1.2851 +			PRINT((_L("CVDecTestEngine::SaveAndReturnPicture,  Output data stored: count[%d]"),iReturnedBuffCount))
  1.2852 +
  1.2853 +
  1.2854 +		}
  1.2855 +	}
  1.2856 +
  1.2857 +	if (iSetSlowClient)
  1.2858 +	{
  1.2859 +		if (iOutBufferTemp)
  1.2860 +		{
  1.2861 +			PRINT((_L("CVDecTestEngine::SaveAndReturnPicture, returning previous buffer (slow client)")))
  1.2862 +
  1.2863 +			iDevvp->ReturnPicture(iOutBufferTemp);
  1.2864 +		}
  1.2865 +		iOutBufferTemp = iOutBuffer;
  1.2866 +	}
  1.2867 +	else
  1.2868 +	{
  1.2869 +		PRINT((_L("CVDecTestEngine::SaveAndReturnPicture, returning buffer")))
  1.2870 +		iDevvp->ReturnPicture(iOutBuffer);
  1.2871 +	}
  1.2872 +
  1.2873 +
  1.2874 +	iOutBuffer = NULL;
  1.2875 +
  1.2876 +	if ( err != KErrNone )
  1.2877 +	{
  1.2878 +		//iInputEnd = ETrue; Fix for MRII-7HW9R3
  1.2879 +		iError = err;
  1.2880 +		PRINT((_L("CVDecTestEngine::SaveAndReturnPicture, Error in store data: [%d]"),iError))
  1.2881 +	}
  1.2882 +
  1.2883 +	PRINT((_L("CVDecTestEngine::SaveAndReturnPicture, Out")))
  1.2884 +}
  1.2885 +
  1.2886 +
  1.2887 +
  1.2888 +/* ----------------------------------------------------------------------------
  1.2889 +* Name:       CVDecTestEngine::Pause()
  1.2890 +* Purpose:    Pause decoding/postprocessing
  1.2891 +* Note:
  1.2892 +* Parameters: None
  1.2893 +* Return:     None
  1.2894 +* --------------------------------------------------------------------------*/
  1.2895 +
  1.2896 +
  1.2897 +TInt CVDecTestEngine::Pause()
  1.2898 +{
  1.2899 +	TInt err = KErrNone;
  1.2900 +
  1.2901 +	if ( iState == ERunning )
  1.2902 +	{
  1.2903 +		if ( iSynchronized )
  1.2904 +		{
  1.2905 +			iClock->Suspend();  //Stop Clock source
  1.2906 +		}
  1.2907 +		iDevvp->Pause();
  1.2908 +		iState = EPaused;
  1.2909 +		PRINT((_L("CVDecTestEngine::Pause(), Paused")))
  1.2910 +	}
  1.2911 +	else
  1.2912 +	{
  1.2913 +		err = KErrGeneral;
  1.2914 +	}
  1.2915 +	return err;
  1.2916 +}
  1.2917 +
  1.2918 +
  1.2919 +/* ----------------------------------------------------------------------------
  1.2920 +* Name:       CVDecTestEngine::Resume()
  1.2921 +* Purpose:    Resume decoding/postprocessing
  1.2922 +* Note:
  1.2923 +* Parameters: None
  1.2924 +* Return:     None
  1.2925 +* --------------------------------------------------------------------------*/
  1.2926 +
  1.2927 +TInt CVDecTestEngine::Resume()
  1.2928 +{
  1.2929 +
  1.2930 +	TInt err = KErrNone;
  1.2931 +
  1.2932 +	if ( iState == EPaused )
  1.2933 +	{
  1.2934 +		if ( iSynchronized )
  1.2935 +		{
  1.2936 +			iClock->Resume();  //Restart Clock source
  1.2937 +		}
  1.2938 +		iDevvp->Resume();
  1.2939 +		iState = ERunning;
  1.2940 +		PRINT((_L("CVDecTestEngine::Resume(), Resumed")))
  1.2941 +
  1.2942 +		/*if ( iDecHWDevId )
  1.2943 +		{
  1.2944 +		if ( iDevvp->NumFreeBuffers() )
  1.2945 +		{
  1.2946 +		iDecTestAO->RequestData();   //Restart data transfer
  1.2947 +		}
  1.2948 +		else
  1.2949 +		{
  1.2950 +		PRINT((_L("CVDecTestEngine::Resume, No input buffer available now")));
  1.2951 +		}
  1.2952 +		}*/
  1.2953 +		iDecTestAO->RequestData();
  1.2954 +	}
  1.2955 +	else
  1.2956 +	{
  1.2957 +		err = KErrGeneral;
  1.2958 +	}
  1.2959 +
  1.2960 +	return err;
  1.2961 +}
  1.2962 +
  1.2963 +
  1.2964 +/* ----------------------------------------------------------------------------
  1.2965 +* Name:       CVDecTestEngine::FreezePicture()
  1.2966 +* Purpose:    Freeze decoding/postprocessing
  1.2967 +* Note:
  1.2968 +* Parameters: TTimeIntervalMicroSeconds aTimeStamp
  1.2969 +* Return:     None
  1.2970 +* --------------------------------------------------------------------------*/
  1.2971 +
  1.2972 +void CVDecTestEngine::FreezePicture(TTimeIntervalMicroSeconds aTimeStamp)
  1.2973 +{
  1.2974 +	iDevvp->FreezePicture(aTimeStamp);
  1.2975 +	PRINT((_L("CVDecTestEngine::Freeze(), Freezed: timestamp[%ld]"), aTimeStamp.Int64()))
  1.2976 +}
  1.2977 +
  1.2978 +
  1.2979 +/* ----------------------------------------------------------------------------
  1.2980 +* Name:       CVDecTestEngine::ReleaseFreeze()
  1.2981 +* Purpose:    Release Freeze
  1.2982 +* Note:
  1.2983 +* Parameters: TTimeIntervalMicroSeconds aTimeStamp
  1.2984 +* Return:     None
  1.2985 +* --------------------------------------------------------------------------*/
  1.2986 +
  1.2987 +
  1.2988 +void CVDecTestEngine::ReleaseFreeze(TTimeIntervalMicroSeconds aTimeStamp)
  1.2989 +{
  1.2990 +	iDevvp->ReleaseFreeze(aTimeStamp);
  1.2991 +	PRINT((_L("CVDecTestEngine::ReleaseFreeze(), Freeze released")))
  1.2992 +}
  1.2993 +
  1.2994 +
  1.2995 +/* ----------------------------------------------------------------------------
  1.2996 +* Name:       CVDecTestEngine::StartDirectScreenAccessL
  1.2997 +* Purpose:    Start DirectScreenAccess
  1.2998 +* Note:
  1.2999 +* Parameters: None
  1.3000 +* Return:     None
  1.3001 +* --------------------------------------------------------------------------*/
  1.3002 +
  1.3003 +void CVDecTestEngine::StartDirectScreenAccessL(TRect aVideoRect, TRect aClipRegion)
  1.3004 +{
  1.3005 +	PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL(), In")))
  1.3006 +	if (!iScreenDevice)
  1.3007 +	{
  1.3008 +		User::LeaveIfError (RFbsSession::Connect());
  1.3009 +		PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL, connected to Fbs server :")))
  1.3010 +		TInt err = KErrNone;
  1.3011 +		if( iUseSecondScreen )
  1.3012 +		{
  1.3013 +			TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(1, EColor16MU));
  1.3014 +		}
  1.3015 +		else
  1.3016 +		{
  1.3017 +			TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(0, EColor16MU));
  1.3018 +		}
  1.3019 +		if( err == KErrNotSupported )
  1.3020 +		{
  1.3021 +			PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL, EColor16MU is not supported, ")))
  1.3022 +			if( iUseSecondScreen )
  1.3023 +			{
  1.3024 +				TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(1, EColor16MA));
  1.3025 +			}
  1.3026 +			else
  1.3027 +			{
  1.3028 +				TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(0, EColor16MA));
  1.3029 +			}
  1.3030 +		}
  1.3031 +
  1.3032 +		if( err != KErrNone )
  1.3033 +		{
  1.3034 +			PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL, couldn't initialize screen device, err[%d]"),err))
  1.3035 +		}
  1.3036 +
  1.3037 +		else
  1.3038 +		{
  1.3039 +			iMemAlloc++;
  1.3040 +			#ifdef __MEM_CHECK_
  1.3041 +			PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL, mem alloc, iScreenDevice") ))
  1.3042 +			#endif
  1.3043 +		}
  1.3044 +	}
  1.3045 +
  1.3046 +	TRegionFix<1> region(aClipRegion);
  1.3047 +
  1.3048 +	//Start DSA
  1.3049 +	iDevvp->StartDirectScreenAccessL(aVideoRect, *iScreenDevice, region);
  1.3050 +	PRINT((_L("CVDecTestEngine::Start, DSA started")))
  1.3051 +	iDsaStarted = ETrue;
  1.3052 +
  1.3053 +	PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL(), Out")))
  1.3054 +}
  1.3055 +
  1.3056 +/* ----------------------------------------------------------------------------
  1.3057 +* Name:       CVDecTestEngine::StartDirectScreenAccessL
  1.3058 +* Purpose:    Start DirectScreenAccess
  1.3059 +* Note:
  1.3060 +* Parameters: None
  1.3061 +* Return:     None
  1.3062 +* --------------------------------------------------------------------------*/
  1.3063 +
  1.3064 +void CVDecTestEngine::StartDirectScreenAccessL()
  1.3065 +{
  1.3066 +	PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL(), In")))
  1.3067 +	if (iDsaStarted)
  1.3068 +	{
  1.3069 +		PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL(), DSA already started- abort first")))
  1.3070 +		AbortDirectScreenAccess();
  1.3071 +	}
  1.3072 +
  1.3073 +	if (!iScreenDevice)
  1.3074 +	{
  1.3075 +
  1.3076 +
  1.3077 +		User::LeaveIfError (RFbsSession::Connect());
  1.3078 +		PRINT((_L("CVDecTestEngine::Start, connected to Fbs server :")))
  1.3079 +
  1.3080 +
  1.3081 +		TInt err = KErrNone;
  1.3082 +		if( iUseSecondScreen )
  1.3083 +		{
  1.3084 +			TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(1, EColor16MU));
  1.3085 +		}
  1.3086 +		else
  1.3087 +		{
  1.3088 +			TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(0, EColor16MU));
  1.3089 +		}
  1.3090 +		//TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(0, EColor16MU));
  1.3091 +		if( err == KErrNotSupported )
  1.3092 +		{
  1.3093 +			PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL, EColor16MU is not supported, ")))
  1.3094 +			if( iUseSecondScreen )
  1.3095 +			{
  1.3096 +				TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(1, EColor16MA));
  1.3097 +			}
  1.3098 +			else
  1.3099 +			{
  1.3100 +				TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(0, EColor16MA));
  1.3101 +			}
  1.3102 +			//TRAP(err, iScreenDevice = CFbsScreenDevice::NewL(0, EColor16MA));
  1.3103 +		}
  1.3104 +
  1.3105 +		if ( err != KErrNone )
  1.3106 +		{
  1.3107 +			PRINT((_L("CVDecTestEngine::Start, couldn't initialize screen device, err[%d]"),err))
  1.3108 +		}
  1.3109 +	}
  1.3110 +
  1.3111 +
  1.3112 +
  1.3113 +	PRINT((_L("CVDecTestEngine::Start, disprect x[%d],y[%d] "),iDispRect.iTl.iX, iDispRect.iTl.iY))
  1.3114 +	PRINT((_L("CVDecTestEngine::Start, disprect width[%d],height[%d] "),iDispRect.Width(),iDispRect.Height()))
  1.3115 +
  1.3116 +
  1.3117 +	TRegionFix<1> region(iDispRect);
  1.3118 +
  1.3119 +	//Start DSA
  1.3120 +	iDevvp->StartDirectScreenAccessL(iDispRect, *iScreenDevice, region);
  1.3121 +	PRINT((_L("CVDecTestEngine::Start, DSA started")))
  1.3122 +	iDsaStarted = ETrue;
  1.3123 +
  1.3124 +
  1.3125 +	PRINT((_L("CVDecTestEngine::StartDirectScreenAccessL(), Out")))
  1.3126 +}
  1.3127 +
  1.3128 +/* ----------------------------------------------------------------------------
  1.3129 +* Name:       CVDecTestEngine::AbortDirectScreenAccess
  1.3130 +* Purpose:    AbortDirectScreenAccess
  1.3131 +* Note:
  1.3132 +* Parameters: None
  1.3133 +* Return:     None
  1.3134 +* --------------------------------------------------------------------------*/
  1.3135 +
  1.3136 +void CVDecTestEngine::AbortDirectScreenAccess()
  1.3137 +{
  1.3138 +	if ( iDirectScreenAccess && iDsaStarted )
  1.3139 +	{
  1.3140 +	iDevvp->AbortDirectScreenAccess();
  1.3141 +	iDsaStarted = EFalse;
  1.3142 +	PRINT((_L("CVDecTestEngine::AbortDirectScreenAccess, aborted ")))
  1.3143 +	}
  1.3144 +}
  1.3145 +
  1.3146 +/* ----------------------------------------------------------------------------
  1.3147 +* Name:       CVDecTestEngine::SetSecureOutputL
  1.3148 +* Purpose:    Set sucure output enable
  1.3149 +* Note:
  1.3150 +* Parameters: TBool aSecure
  1.3151 +* Return:     None
  1.3152 +* --------------------------------------------------------------------------*/
  1.3153 +
  1.3154 +
  1.3155 +void CVDecTestEngine::SetSecureOutputL(TBool aSecure)
  1.3156 +{
  1.3157 +	PRINT((_L("CVDecTestEngine::SetSecureOutputL, In")))
  1.3158 +
  1.3159 +	#ifdef __SECUREOUTPUTCI__
  1.3160 +
  1.3161 +	MMmfVideoSecureOutput* secureOutput = NULL;     // Custom interface Secure output
  1.3162 +
  1.3163 +	secureOutput = (MMmfVideoSecureOutput*)iDevvp->CustomInterface(iPostProcId, KMmfVideoSecureOutputUid);
  1.3164 +
  1.3165 +	if (!secureOutput)
  1.3166 +	{
  1.3167 +		PRINT((_L("CVDecTestEngine::SetSecureOutput, Failed to retrieve Secure CI")))
  1.3168 +		User::Leave(KErrGeneral);
  1.3169 +	}
  1.3170 +
  1.3171 +	secureOutput->MmvsoSetSecureOutputL(aSecure);
  1.3172 +
  1.3173 +	#endif
  1.3174 +
  1.3175 +	PRINT((_L("CVDecTestEngine::SetSecureOutputL, Out [%d]"), aSecure))
  1.3176 +}
  1.3177 +
  1.3178 +/* ----------------------------------------------------------------------------
  1.3179 +* Name:       CVDecTestEngine::SetPosition
  1.3180 +* Purpose:    Set postion
  1.3181 +* Note:
  1.3182 +* Parameters: TTimeIntervalMicroSeconds aTimeStamp
  1.3183 +* Return:     None
  1.3184 +* --------------------------------------------------------------------------*/
  1.3185 +
  1.3186 +
  1.3187 +void CVDecTestEngine::SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition)
  1.3188 +{
  1.3189 +	PRINT((_L("CVDecTestEngine::SetPosition, In")))
  1.3190 +
  1.3191 +	iDevvp->SetPosition(aPlaybackPosition);
  1.3192 +
  1.3193 +	PRINT((_L("CVDecTestEngine::SetPosition, Out")))
  1.3194 +}
  1.3195 +
  1.3196 +/* ----------------------------------------------------------------------------
  1.3197 +* Name:       CVDecTestEngine::ResetPosition
  1.3198 +* Purpose:    Reset postion to start
  1.3199 +* Note:
  1.3200 +* Parameters: TTimeIntervalMicroSeconds aTimeStamp
  1.3201 +* Return:     None
  1.3202 +* --------------------------------------------------------------------------*/
  1.3203 +
  1.3204 +
  1.3205 +void CVDecTestEngine::ResetPosition()
  1.3206 +{
  1.3207 +	PRINT((_L("CVDecTestEngine::ResetPosition, In")))
  1.3208 +	TTimeIntervalMicroSeconds starttime(0);
  1.3209 +
  1.3210 +	iDevvp->SetPosition(starttime);
  1.3211 +	PRINT((_L("CVDecTestEngine::ResetPosition, Reset Position to start of bitstream")))
  1.3212 +
  1.3213 +	if ( iSynchronized )
  1.3214 +	{
  1.3215 +		iClock->Reset(starttime);
  1.3216 +		iTimeStamp = 0;
  1.3217 +		TTimeIntervalMicroSeconds currenttime = iClock->Time();
  1.3218 +		PRINT((_L("CVDecTestEngine::ResetPosition, current time[%ld]"),currenttime.Int64() ))
  1.3219 +	}
  1.3220 +	TInt pos = 0;
  1.3221 +	iInFile.Seek(ESeekStart,pos);
  1.3222 +	iSentBuffCount = 0;
  1.3223 +
  1.3224 +	PRINT((_L("CVDecTestEngine::ResetPosition, In")))
  1.3225 +}
  1.3226 +
  1.3227 +
  1.3228 +
  1.3229 +
  1.3230 +/* ----------------------------------------------------------------------------
  1.3231 +* Name:       CVDecTestEngine::PlaybackPosition
  1.3232 +* Purpose:    Ritrieve Playback Position
  1.3233 +* Note:
  1.3234 +* Parameters: None
  1.3235 +* Return:     None
  1.3236 +* --------------------------------------------------------------------------*/
  1.3237 +
  1.3238 +
  1.3239 +TTimeIntervalMicroSeconds CVDecTestEngine::PlaybackPosition()
  1.3240 +{
  1.3241 +	PRINT((_L("CVDecTestEngine::PlaybackPosition, In")))
  1.3242 +
  1.3243 +	TTimeIntervalMicroSeconds position = iDevvp->PlaybackPosition();
  1.3244 +	PRINT((_L("CVDecTestEngine::PlaybackPosition, Playback Position[%ld]"),position.Int64()))
  1.3245 +
  1.3246 +	PRINT((_L("CVDecTestEngine::PlaybackPosition, Out")))
  1.3247 +	return position;
  1.3248 +}
  1.3249 +
  1.3250 +
  1.3251 +/* ----------------------------------------------------------------------------
  1.3252 +* Name:       CVDecTestEngine::DecodingPosition
  1.3253 +* Purpose:    Ritrieve Decoding Position
  1.3254 +* Note:
  1.3255 +* Parameters: None
  1.3256 +* Return:     None
  1.3257 +* --------------------------------------------------------------------------*/
  1.3258 +
  1.3259 +
  1.3260 +void CVDecTestEngine::DecodingPosition()
  1.3261 +{
  1.3262 +	PRINT((_L("CVDecTestEngine::DecodingPosition, In")))
  1.3263 +
  1.3264 +	TTimeIntervalMicroSeconds position = iDevvp->DecodingPosition();
  1.3265 +	PRINT((_L("CVDecTestEngine::DecodingPosition, Decoding Position[%ld]"),position.Int64()))
  1.3266 +
  1.3267 +	PRINT((_L("CVDecTestEngine::DecodingPosition, Out")))
  1.3268 +}
  1.3269 +
  1.3270 +/* ----------------------------------------------------------------------------
  1.3271 +* Name:       CVDecTestEngine::GetFrameSizeCount
  1.3272 +* Purpose:    Get frame size count after frame sizes are listed
  1.3273 +* Note:       Called after initialization
  1.3274 +* Parameters: None
  1.3275 +* Return:     TInt
  1.3276 +* --------------------------------------------------------------------------*/
  1.3277 +TInt CVDecTestEngine::GetFrameSizeCount()
  1.3278 +    {
  1.3279 +    return iFrameSizeList.Count();
  1.3280 +    }
  1.3281 +
  1.3282 +/* ----------------------------------------------------------------------------
  1.3283 +* Name:       CVDecTestEngine::EnableSynchronization
  1.3284 +* Purpose:    Set Clock and enable synchronization
  1.3285 +* Note:       Called before initialization and after Decoder/post-processor selected
  1.3286 +* Parameters: TInt aFrameRate
  1.3287 +* Return:     None
  1.3288 +* --------------------------------------------------------------------------*/
  1.3289 +
  1.3290 +void CVDecTestEngine::EnableSynchronization(TInt aFrameRate)
  1.3291 +{
  1.3292 +	PRINT((_L("CVDecTestEngine::EnableSynchronization, In")))
  1.3293 +
  1.3294 +	iDevvp->SetClockSource(iClock);
  1.3295 +	PRINT((_L("CVDecTestEngine::Synchronization, Clock source set")))
  1.3296 +
  1.3297 +	iSynchronized = ETrue;
  1.3298 +	iFrameTimeInterval = (TInt64)(1000000/aFrameRate);
  1.3299 +	PRINT((_L("CVDecTestEngine::Synchronization, Frame rate:[%d]"),aFrameRate ))
  1.3300 +
  1.3301 +	PRINT((_L("CVDecTestEngine::EnableSynchronization, Out")))
  1.3302 +}
  1.3303 +
  1.3304 +
  1.3305 +/* ----------------------------------------------------------------------------
  1.3306 +* Name:       CVDecTestEngine::SetWindowRect
  1.3307 +* Purpose:    Set sucure output enable
  1.3308 +* Note:
  1.3309 +* Parameters: TInt aX, TInt aY, TSize aSize
  1.3310 +* Return:     None
  1.3311 +* --------------------------------------------------------------------------*/
  1.3312 +
  1.3313 +void CVDecTestEngine::SetWindowRect(TInt aX, TInt aY, TSize aSize )
  1.3314 +{
  1.3315 +
  1.3316 +	iDispRect.SetRect(TPoint(aX,aY),aSize);
  1.3317 +
  1.3318 +	PRINT((_L("CVDecTestEngine::SetWindowRect, [%d], [%d]"),aX ,aY ))
  1.3319 +	PRINT((_L("CVDecTestEngine::SetWindowRect, width[%d], height[%d]"),aSize.iWidth, aSize.iHeight))
  1.3320 +}
  1.3321 +
  1.3322 +
  1.3323 +/* ----------------------------------------------------------------------------
  1.3324 +* Name:       CVDecTestEngine::ListFrameSizeL
  1.3325 +* Purpose:    List size of each frmae of coded bitstream for synchrinized
  1.3326 +*             playback
  1.3327 +* Note:
  1.3328 +* Parameters: None
  1.3329 +* Return:     None
  1.3330 +* --------------------------------------------------------------------------*/
  1.3331 +
  1.3332 +void CVDecTestEngine::ListFrameSizeL(RArray<TInt> aFramesizes)
  1.3333 +{
  1.3334 +
  1.3335 +	if ( iCodecType == EVC1 ){
  1.3336 +
  1.3337 +		PRINT((_L("CVDecTestEngine::ListFrameSizeL, not supported for VC1") ))
  1.3338 +		User::Leave(KErrGeneral);
  1.3339 +	}
  1.3340 +
  1.3341 +	TInt framesize = 0;
  1.3342 +	TVideoInputBuffer* videoBuffer = new(ELeave) TVideoInputBuffer;
  1.3343 +	iMemAlloc++;
  1.3344 +	HBufC8* tempBuff = HBufC8::NewL(iInBuffSize);
  1.3345 +	iMemAlloc++;
  1.3346 +	#ifdef __MEM_CHECK_
  1.3347 +	PRINT((_L("CVDecTestEngine::ListFrameSizeL, mem alloc, videoBuffer & iInBuffSize") ))
  1.3348 +	#endif
  1.3349 +	videoBuffer->iData.Set(tempBuff->Des());
  1.3350 +	//iListFrameSize = ETrue;
  1.3351 +
  1.3352 +	if(aFramesizes.Count() > 0)
  1.3353 +	{
  1.3354 +		for (TUint i = 0; i < aFramesizes.Count(); i++)
  1.3355 +		{
  1.3356 +			iFrameSizeList.AppendL(aFramesizes[i]);
  1.3357 +			PRINT((_L("CVDecTestEngine::ListFrameSize, user input [%d]"),aFramesizes[i]))
  1.3358 +		}
  1.3359 +
  1.3360 +	}
  1.3361 +	else
  1.3362 +	{
  1.3363 +		while (!iInputEnd)
  1.3364 +		{
  1.3365 +			videoBuffer->iData.SetLength(0);
  1.3366 +			framesize = ReadOneCodedPicture(videoBuffer);
  1.3367 +			PRINT((_L("CVDecTestEngine::ListFrameSize, frame size[%d]"),framesize))
  1.3368 +			// here append frame size in list
  1.3369 +
  1.3370 +			if (framesize >= 0 )
  1.3371 +			{
  1.3372 +				iFrameSizeList.AppendL(framesize);
  1.3373 +				iSentBuffCount++;
  1.3374 +			}
  1.3375 +			else
  1.3376 +			{
  1.3377 +				break;
  1.3378 +			}
  1.3379 +
  1.3380 +		}
  1.3381 +	}
  1.3382 +	PRINT((_L("CVDecTestEngine::ListFrameSize, frame count[%d]"),iFrameSizeList.Count()))
  1.3383 +
  1.3384 +	// cleanup
  1.3385 +	//Reset file postion to start
  1.3386 +	TInt pos =0;
  1.3387 +	iSentBuffCount = 0;
  1.3388 +	iReadDataChunk = iDataChunk;
  1.3389 +	iWriteDataChunk = iDataChunk;
  1.3390 +	iDataReadFromFile = 0;
  1.3391 +	iInFile.Seek(ESeekStart,pos);
  1.3392 +
  1.3393 +	iInputEnd = EFalse;
  1.3394 +
  1.3395 +	delete tempBuff;
  1.3396 +	delete videoBuffer;
  1.3397 +	iMemDelete += 2;
  1.3398 +	#ifdef __MEM_CHECK_
  1.3399 +	PRINT((_L("CVDecTestEngine::ListFrameSize, mem del, tempBuff & videoBuffer") ))
  1.3400 +	#endif
  1.3401 +	if ( framesize < 0)
  1.3402 +	{
  1.3403 +        PRINT((_L("CVDecTestEngine::ListFrameSize, error[%d]"),framesize ))
  1.3404 +		User::Leave(framesize);
  1.3405 +	}
  1.3406 +
  1.3407 +}
  1.3408 +
  1.3409 +
  1.3410 +/* ----------------------------------------------------------------------------
  1.3411 +* Name:       CVDecTestEngine::SetLandscapeMode()
  1.3412 +* Purpose:    Set landscape mode flag
  1.3413 +* Note:
  1.3414 +* Parameters: None
  1.3415 +* Return:     None
  1.3416 +* --------------------------------------------------------------------------*/
  1.3417 +
  1.3418 +/*
  1.3419 +void CVDecTestEngine::SetLandscapeMode()
  1.3420 +{
  1.3421 +
  1.3422 +iLandscapeMode = ETrue;
  1.3423 +PRINT((_L("CVDecTestEngine::SetLandscapeMode, Landscape mode is set") ))
  1.3424 +
  1.3425 +}
  1.3426 +*/
  1.3427 +
  1.3428 +/* ----------------------------------------------------------------------------
  1.3429 +* Name:       CVDecTestEngine::SelectDecoderL()
  1.3430 +* Purpose:
  1.3431 +* Note:
  1.3432 +* Parameters: None
  1.3433 +* Return:     None
  1.3434 +* --------------------------------------------------------------------------*/
  1.3435 +void CVDecTestEngine::SelectDecoderL(const TUid& aUid)
  1.3436 +{
  1.3437 +	PRINT((_L("CVDecTestEngine::SelectDecoderL, In") ))
  1.3438 +
  1.3439 +	iDecoderUid = aUid;
  1.3440 +	iDecHWDevId = iDevvp->SelectDecoderL(aUid);
  1.3441 +
  1.3442 +	#ifdef __RESOURCENOTIFICATION__
  1.3443 +	MMmfVideoResourceHandler* handler = (MMmfVideoResourceHandler*)iDevvp->CustomInterface(iDecHWDevId, KUidMmfVideoResourceManagement );
  1.3444 +	handler->MmvrhSetObserver(((MMmfVideoResourceObserver*)(this)));
  1.3445 +	#endif
  1.3446 +
  1.3447 +	PRINT((_L("CVDecTestEngine::SelectDecoderL, Out") ))
  1.3448 +}
  1.3449 +
  1.3450 +/* ----------------------------------------------------------------------------
  1.3451 +* Name:       CVDecTestEngine::SelectPostProcessorL()
  1.3452 +* Purpose:
  1.3453 +* Note:
  1.3454 +* Parameters: None
  1.3455 +* Return:     None
  1.3456 +* --------------------------------------------------------------------------*/
  1.3457 +void CVDecTestEngine::SelectPostProcessorL(const TUid& aUid)
  1.3458 +{
  1.3459 +	PRINT((_L("CVDecTestEngine::SelectPostProcessorL, In") ))
  1.3460 +
  1.3461 +	iPostProcessorUid = aUid;
  1.3462 +	iPostProcId = iDevvp->SelectPostProcessorL(aUid);
  1.3463 +
  1.3464 +	PRINT((_L("CVDecTestEngine::SelectPostProcessorL, Out") ))
  1.3465 +}
  1.3466 +
  1.3467 +/* ----------------------------------------------------------------------------
  1.3468 +* Name:       CVDecTestEngine::SetBufferOptionsL()
  1.3469 +* Purpose:
  1.3470 +* Note:
  1.3471 +* Parameters: None
  1.3472 +* Return:     None
  1.3473 +* --------------------------------------------------------------------------*/
  1.3474 +void CVDecTestEngine::SetBufferOptionsL(const CMMFDevVideoPlay::TBufferOptions& aOptions)
  1.3475 +{
  1.3476 +	PRINT((_L("CVDecTestEngine::SetBufferOptionsL, In") ))
  1.3477 +
  1.3478 +	iInBuffSize = aOptions.iMaxInputBufferSize;
  1.3479 +	iDevvp->SetBufferOptionsL(aOptions);
  1.3480 +
  1.3481 +	PRINT((_L("CVDecTestEngine::SetBufferOptionsL, Out") ))
  1.3482 +}
  1.3483 +
  1.3484 +/* ----------------------------------------------------------------------------
  1.3485 +* Name:       CVDecTestEngine::SetVideoDestScreenL()
  1.3486 +* Purpose:
  1.3487 +* Note:
  1.3488 +* Parameters: None
  1.3489 +* Return:     None
  1.3490 +* --------------------------------------------------------------------------*/
  1.3491 +void CVDecTestEngine::SetVideoDestScreenL(TBool aDest)
  1.3492 +{
  1.3493 +	PRINT((_L("CVDecTestEngine::SetVideoDestScreenL, In") ))
  1.3494 +
  1.3495 +	iDevvp->SetVideoDestScreenL(aDest);
  1.3496 +
  1.3497 +	PRINT((_L("CVDecTestEngine::SetVideoDestScreenL, Out") ))
  1.3498 +}
  1.3499 +
  1.3500 +/* ----------------------------------------------------------------------------
  1.3501 +* Name:       CVDecTestEngine::SynchronizeDecoding()
  1.3502 +* Purpose:
  1.3503 +* Note:
  1.3504 +* Parameters: None
  1.3505 +* Return:     None
  1.3506 +* --------------------------------------------------------------------------*/
  1.3507 +void CVDecTestEngine::SynchronizeDecoding(TBool aSynch)
  1.3508 +{
  1.3509 +	PRINT((_L("CVDecTestEngine::SynchronizeDecoding, In") ))
  1.3510 +
  1.3511 +	iDevvp->SynchronizeDecoding(aSynch);
  1.3512 +
  1.3513 +	PRINT((_L("CVDecTestEngine::SynchronizeDecoding, Out") ))
  1.3514 +}
  1.3515 +
  1.3516 +/* ----------------------------------------------------------------------------
  1.3517 +* Name:       CVDecTestEngine::GetBufferOptions()
  1.3518 +* Purpose:
  1.3519 +* Note:
  1.3520 +* Parameters: None
  1.3521 +* Return:     None
  1.3522 +* --------------------------------------------------------------------------*/
  1.3523 +void CVDecTestEngine::GetBufferOptions()
  1.3524 +{
  1.3525 +	PRINT((_L("CVDecTestEngine::GetBufferOptions, In") ))
  1.3526 +
  1.3527 +	CMMFDevVideoPlay::TBufferOptions options;
  1.3528 +	iDevvp->GetBufferOptions(options);
  1.3529 +
  1.3530 +	PRINT((_L("CVDecTestEngine::GetBufferOptions: iPreDecodeBufferSize: [%d]\n iMaxPostDecodeBufferSize: [%d]\n"),
  1.3531 +	options.iPreDecodeBufferSize, options.iMaxPostDecodeBufferSize))
  1.3532 +	PRINT((_L("CVDecTestEngine::GetBufferOptions: iMaxInputBufferSize [%d]\n iMinNumInputBuffers [%d]\n "),
  1.3533 +	options.iMaxInputBufferSize, options.iMinNumInputBuffers))
  1.3534 +	PRINT((_L("CVDecTestEngine::GetBufferOptions: iPreDecoderBufferPeriod [%d] [%d]"), I64LOW(options.iPreDecoderBufferPeriod.Int64()), I64HIGH(options.iPreDecoderBufferPeriod.Int64())))
  1.3535 +	PRINT((_L("CVDecTestEngine::GetBufferOptions: iPostDecoderBufferPeriod [%d] [%d]"), I64LOW(options.iPostDecoderBufferPeriod.Int64()), I64HIGH(options.iPostDecoderBufferPeriod.Int64())))
  1.3536 +
  1.3537 +	PRINT((_L("CVDecTestEngine::GetBufferOptions, Out") ))
  1.3538 +}
  1.3539 +
  1.3540 +/* ----------------------------------------------------------------------------
  1.3541 +* Name:       CVDecTestEngine::SetInputFormatL()
  1.3542 +* Purpose:
  1.3543 +* Note:
  1.3544 +* Parameters: None
  1.3545 +* Return:     None
  1.3546 +* --------------------------------------------------------------------------*/
  1.3547 +void CVDecTestEngine::SetInputFormatL(TInt aHwDev, const TUncompressedVideoFormat& aFormat)
  1.3548 +{
  1.3549 +	PRINT((_L("CVDecTestEngine::SetInputFormatL, In") ))
  1.3550 +
  1.3551 +	if (aHwDev == EPostProcessor)
  1.3552 +	{
  1.3553 +		iDevvp->SetInputFormatL(iPostProcId, aFormat);
  1.3554 +	}
  1.3555 +	else
  1.3556 +	{
  1.3557 +		iDevvp->SetInputFormatL(iDecHWDevId, aFormat);
  1.3558 +	}
  1.3559 +
  1.3560 +	PRINT((_L("CVDecTestEngine::SetInputFormatL, Out") ))
  1.3561 +}
  1.3562 +
  1.3563 +/* ----------------------------------------------------------------------------
  1.3564 +* Name:       CVDecTestEngine::SetOutputFormatL()
  1.3565 +* Purpose:
  1.3566 +* Note:
  1.3567 +* Parameters: None
  1.3568 +* Return:     None
  1.3569 +* --------------------------------------------------------------------------*/
  1.3570 +void CVDecTestEngine::SetOutputFormatL(TInt aHwDev, const TUncompressedVideoFormat& aFormat)
  1.3571 +{
  1.3572 +	PRINT((_L("CVDecTestEngine::SetOutputFormatL, In") ))
  1.3573 +
  1.3574 +	if (aHwDev == EPostProcessor)
  1.3575 +	{
  1.3576 +		iDevvp->SetOutputFormatL(iPostProcId, aFormat);
  1.3577 +	}
  1.3578 +	else
  1.3579 +	{
  1.3580 +		iDevvp->SetOutputFormatL(iDecHWDevId, aFormat);
  1.3581 +	}
  1.3582 +
  1.3583 +	PRINT((_L("CVDecTestEngine::SetOutputFormatL, Out") ))
  1.3584 +}
  1.3585 +
  1.3586 +/* ----------------------------------------------------------------------------
  1.3587 +* Name:       CVDecTestEngine::SetInputFormatL()
  1.3588 +* Purpose:
  1.3589 +* Note:
  1.3590 +* Parameters: None
  1.3591 +* Return:     None
  1.3592 +* --------------------------------------------------------------------------*/
  1.3593 +void CVDecTestEngine::SetInputFormatL(TInt aHwDev, const CCompressedVideoFormat& aFormat,
  1.3594 +TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aEncapsulation,
  1.3595 +TBool aDataInOrder)
  1.3596 +{
  1.3597 +	PRINT((_L("CVDecTestEngine::SetInputFormatL, In") ))
  1.3598 +
  1.3599 +	if (aHwDev == EPostProcessor)
  1.3600 +	{
  1.3601 +		iDevvp->SetInputFormatL(iPostProcId, aFormat, aDataUnitType, aEncapsulation, aDataInOrder);
  1.3602 +	}
  1.3603 +	else
  1.3604 +	{
  1.3605 +		iDevvp->SetInputFormatL(iDecHWDevId, aFormat, aDataUnitType, aEncapsulation, aDataInOrder);
  1.3606 +	}
  1.3607 +
  1.3608 +	PRINT((_L("CVDecTestEngine::SetInputFormatL, Out") ))
  1.3609 +}
  1.3610 +
  1.3611 +/* ----------------------------------------------------------------------------
  1.3612 +* Name:       CVDecTestEngine::FindCommonFormats()
  1.3613 +* Purpose:
  1.3614 +* Note:
  1.3615 +* Parameters: None
  1.3616 +* Return:     None
  1.3617 +* --------------------------------------------------------------------------*/
  1.3618 +void CVDecTestEngine::FindCommonFormatsL()
  1.3619 +{
  1.3620 +	PRINT((_L("CVDecTestEngine::FindCommonFormatsL, In") ))
  1.3621 +
  1.3622 +	// Set Output Format for Decoder/Input Format for Postprocessor
  1.3623 +	RArray<TUncompressedVideoFormat> decformats;
  1.3624 +	TUncompressedVideoFormat commonFormat;
  1.3625 +
  1.3626 +
  1.3627 +	iDevvp->GetOutputFormatListL(iDecHWDevId, decformats);
  1.3628 +
  1.3629 +	CPostProcessorInfo* info;
  1.3630 +
  1.3631 +	info = iDevvp->PostProcessorInfoLC(iPostProcessorUid);
  1.3632 +
  1.3633 +	RArray<TUncompressedVideoFormat> ppformats;
  1.3634 +	ppformats = info->SupportedFormats();
  1.3635 +
  1.3636 +	//Find common format for dec output and postproc input
  1.3637 +	TBool found = iDevvp->FindCommonFormat(decformats.Array(), ppformats.Array(), commonFormat);
  1.3638 +
  1.3639 +	if (found)
  1.3640 +	{
  1.3641 +		iDevvp->SetOutputFormatL(iDecHWDevId, commonFormat);
  1.3642 +		PRINT((_L("CVDecTestEngine::FindCommonFormatsL, Decoder output Format set")))
  1.3643 +		iDevvp->SetInputFormatL(iPostProcId, commonFormat);
  1.3644 +		PRINT((_L("CVDecTestEngine::FindCommonFormatsL, Postprocessor input format set.")))
  1.3645 +		PrintUncompressedFormat(commonFormat);
  1.3646 +	}
  1.3647 +	else
  1.3648 +	{
  1.3649 +		PRINT((_L("CVDecTestEngine::FindCommonFormatsL, Common Format not found")))
  1.3650 +		User::Leave( KErrNotFound);
  1.3651 +	}
  1.3652 +	CleanupStack::PopAndDestroy(info);
  1.3653 +	PRINT((_L("CVDecTestEngine::FindCommonFormatsL, closing array") ))
  1.3654 +	decformats.Close();
  1.3655 +	PRINT((_L("CVDecTestEngine::FindCommonFormatsL, Out") ))
  1.3656 +}
  1.3657 +
  1.3658 +/* ----------------------------------------------------------------------------
  1.3659 +* Name:       CVDecTestEngine::FindDecodersL()
  1.3660 +* Purpose:
  1.3661 +* Note:
  1.3662 +* Parameters: None
  1.3663 +* Return:     None
  1.3664 +* --------------------------------------------------------------------------*/
  1.3665 +TInt CVDecTestEngine::FindDecodersL(const TDesC8& aMimeType, TUint32 aPostProcType, TBool aExactMatch, TUid& aUid )
  1.3666 +{
  1.3667 +	PRINT((_L("CVDecTestEngine::FindDecodersL, In") ))
  1.3668 +
  1.3669 +	TInt supports = KErrNotSupported;
  1.3670 +
  1.3671 +	//UID is not set
  1.3672 +	if (aUid.iUid == 0 && !aExactMatch)
  1.3673 +	{
  1.3674 +		supports = KErrNone;
  1.3675 +	}
  1.3676 +
  1.3677 +	RArray<TUid> decoders;
  1.3678 +	CleanupClosePushL(decoders);
  1.3679 +	iDevvp->FindDecodersL(aMimeType, aPostProcType, decoders, aExactMatch);
  1.3680 +	for (TUint i = 0; i < decoders.Count(); i++)
  1.3681 +	{
  1.3682 +		if (decoders[i].iUid == aUid.iUid)
  1.3683 +		{
  1.3684 +			supports = KErrNone;
  1.3685 +		}
  1.3686 +
  1.3687 +		PRINT((_L("CVDecTestEngine::FindDecodersL, Uid [%x]"), decoders[i].iUid ))
  1.3688 +	}
  1.3689 +	CleanupStack::PopAndDestroy(&decoders);
  1.3690 +
  1.3691 +	PRINT((_L("CVDecTestEngine::FindDecodersL, Out") ))
  1.3692 +
  1.3693 +	return supports;
  1.3694 +}
  1.3695 +
  1.3696 +/* ----------------------------------------------------------------------------
  1.3697 +* Name:       CVDecTestEngine::FindPostProcessorsL()
  1.3698 +* Purpose:
  1.3699 +* Note:
  1.3700 +* Parameters: None
  1.3701 +* Return:     None
  1.3702 +* --------------------------------------------------------------------------*/
  1.3703 +TInt CVDecTestEngine::FindPostProcessorsL(TUid& aUid, TUint32 aPostProcType)
  1.3704 +{
  1.3705 +	PRINT((_L("CVDecTestEngine::FindPostProcessorsL, In") ))
  1.3706 +
  1.3707 +	TInt supports = KErrNotSupported;
  1.3708 +
  1.3709 +	//UID is not set
  1.3710 +	if (aUid.iUid == 0)
  1.3711 +	{
  1.3712 +		supports = KErrNone;
  1.3713 +	}
  1.3714 +
  1.3715 +	RArray<TUid> postProcessors;
  1.3716 +	CleanupClosePushL(postProcessors);
  1.3717 +	iDevvp->FindPostProcessorsL(aPostProcType, postProcessors);
  1.3718 +	for (TUint i = 0; i < postProcessors.Count(); i++)
  1.3719 +	{
  1.3720 +		PRINT((_L("CVDecTestEngine::FindPostProcessorsL, Uid [%x]"), postProcessors[i].iUid ))
  1.3721 +
  1.3722 +		if (postProcessors[i].iUid == aUid.iUid)
  1.3723 +		{
  1.3724 +			supports = KErrNone;
  1.3725 +		}
  1.3726 +
  1.3727 +	}
  1.3728 +	CleanupStack::PopAndDestroy(&postProcessors);
  1.3729 +
  1.3730 +	PRINT((_L("CVDecTestEngine::FindPostProcessorsL, Out") ))
  1.3731 +	return supports;
  1.3732 +}
  1.3733 +
  1.3734 +/* ----------------------------------------------------------------------------
  1.3735 +* Name:       CVDecTestEngine::GetDecoderListL()
  1.3736 +* Purpose:
  1.3737 +* Note:
  1.3738 +* Parameters: None
  1.3739 +* Return:     None
  1.3740 +* --------------------------------------------------------------------------*/
  1.3741 +void CVDecTestEngine::GetDecoderListL()
  1.3742 +{
  1.3743 +	PRINT((_L("CVDecTestEngine::GetDecoderListL, In") ))
  1.3744 +
  1.3745 +	RArray<TUid> decoders;
  1.3746 +	CleanupClosePushL(decoders);
  1.3747 +	iDevvp->GetDecoderListL(decoders);
  1.3748 +	for (TUint i = 0; i < decoders.Count(); i++)
  1.3749 +	{
  1.3750 +		PRINT((_L("CVDecTestEngine::GetDecoderListL, Uid [%x]"), decoders[i].iUid ))
  1.3751 +	}
  1.3752 +	CleanupStack::PopAndDestroy(&decoders);
  1.3753 +
  1.3754 +	PRINT((_L("CVDecTestEngine::GetDecoderListL, Out") ))
  1.3755 +}
  1.3756 +
  1.3757 +/* ----------------------------------------------------------------------------
  1.3758 +* Name:       CVDecTestEngine::ConfigureDecoderL()
  1.3759 +* Purpose:
  1.3760 +* Note:
  1.3761 +* Parameters: None
  1.3762 +* Return:     None
  1.3763 +* --------------------------------------------------------------------------*/
  1.3764 +void CVDecTestEngine::ConfigureDecoderL(TVideoPictureHeader& aVideoPictureHeader)
  1.3765 +{
  1.3766 +	PRINT((_L("CVDecTestEngine::ConfigureDecoderL, In") ))
  1.3767 +
  1.3768 +	if( iSetPassword )
  1.3769 +	{
  1.3770 +		TBuf16<128> tempBuf;
  1.3771 +		tempBuf.Copy( iPasswordForFLV);
  1.3772 +		PRINT( ( _L( "CVDecTestEngine::ConfigureDecoderL(): password tempBuf: %S." ), &tempBuf ) )
  1.3773 +
  1.3774 +		TPtrC8 metaData((TUint8*)iPasswordForFLV.Ptr(), iPasswordForFLV.Size());
  1.3775 +
  1.3776 +		aVideoPictureHeader.iOptional = &metaData;
  1.3777 +
  1.3778 +	}
  1.3779 +
  1.3780 +	iDevvp->ConfigureDecoderL(aVideoPictureHeader);
  1.3781 +
  1.3782 +	PRINT((_L("CVDecTestEngine::ConfigureDecoderL, Out") ))
  1.3783 +}
  1.3784 +
  1.3785 +
  1.3786 +/* ----------------------------------------------------------------------------
  1.3787 +* Name:       CVDecTestEngine::ConfigureDecoderL()
  1.3788 +* Purpose:
  1.3789 +* Note:
  1.3790 +* Parameters: None
  1.3791 +* Return:     None
  1.3792 +* --------------------------------------------------------------------------*/
  1.3793 +void CVDecTestEngine::ConfigureDecoderL()
  1.3794 +{
  1.3795 +	PRINT((_L("CVDecTestEngine::ConfigureDecoderL, In") ))
  1.3796 +
  1.3797 +	if (iCodecType == EVC1)
  1.3798 +	{
  1.3799 +		PRINT((_L("CVDecTestEngine::ConfigureDecoderL, iCodectype VC1") ))
  1.3800 +		TInt configPosition = 0;
  1.3801 +		TUint configDataSize = 36; // MetaData is 36 Bytes in SP-L0 VC1 .
  1.3802 +		TUint8* ptr = new (ELeave) TUint8[configDataSize+8];
  1.3803 +		iMemAlloc++;
  1.3804 +		#ifdef __MEM_CHECK_
  1.3805 +		PRINT((_L("CVDecTestEngine::ConfigureDecoderL, mem alloc, ptr") ))
  1.3806 +		#endif
  1.3807 +		TUint32* ptr32 = reinterpret_cast<TUint32*>(ptr);
  1.3808 +		ptr32[0] = 1;
  1.3809 +		ptr32[1] = 44;
  1.3810 +		TPtr8 configData((ptr+8), configDataSize);
  1.3811 +		for (TUint i=0; i < 8; i++)
  1.3812 +		{
  1.3813 +			PRINT((_L("CVDecTestEngine::ConfigureDecoderL, beginning [%d]"), ptr[i] ))
  1.3814 +		}
  1.3815 +
  1.3816 +		User::LeaveIfError(iInFile.Seek(ESeekStart, configPosition));
  1.3817 +		User::LeaveIfError(iInFile.Read(configData, configDataSize));
  1.3818 +		TVideoPictureHeader* configHeader = new TVideoPictureHeader;
  1.3819 +		iMemAlloc++;
  1.3820 +		CleanupStack::PushL(configHeader);
  1.3821 +		#ifdef __MEM_CHECK_
  1.3822 +		PRINT((_L("CVDecTestEngine::ConfigureDecoderL, mem alloc, configHeader") ))
  1.3823 +		#endif
  1.3824 +
  1.3825 +		TPtrC8 metaData(ptr,configDataSize+8);
  1.3826 +
  1.3827 +
  1.3828 +		configHeader->iOptional = &metaData;
  1.3829 +		configHeader->iLevel = -1;
  1.3830 +		configHeader->iProfile = -1;
  1.3831 +
  1.3832 +		iDevvp->ConfigureDecoderL(*configHeader);
  1.3833 +
  1.3834 +
  1.3835 +		CleanupStack::Pop();
  1.3836 +		delete ptr;
  1.3837 +		iMemDelete++;
  1.3838 +		delete configHeader;
  1.3839 +		iMemDelete++;
  1.3840 +		#ifdef __MEM_CHECK_
  1.3841 +		PRINT((_L("CVDecTestEngine::ConfigureDecoderL, mem del, ptr & configHeader") ))
  1.3842 +		#endif
  1.3843 +		return;
  1.3844 +	}
  1.3845 +
  1.3846 +	TInt err = KErrNone;
  1.3847 +	TVideoPictureHeader* headerInfo = NULL;
  1.3848 +	HBufC8* tempBuff = NULL;
  1.3849 +
  1.3850 +	//Read Picture header : Size is not known
  1.3851 +	TVideoInputBuffer* codedBuffer = new(ELeave) TVideoInputBuffer;
  1.3852 +	CleanupStack::PushL( codedBuffer );
  1.3853 +	iInBuffSize = KMaxCodedSize;
  1.3854 +	err = KErrOverflow;
  1.3855 +
  1.3856 +	while ( (err == KErrOverflow) && (iInBuffSize <= KMaxCodedSize) )
  1.3857 +	{
  1.3858 +		tempBuff = HBufC8::NewL(iInBuffSize);
  1.3859 +		CleanupStack::PushL( tempBuff );
  1.3860 +		codedBuffer->iData.Set(tempBuff->Des());
  1.3861 +
  1.3862 +		if ( iFrameSizeList.Count() > 0 )
  1.3863 +		{
  1.3864 +			err = ReadOneCodedPicture(codedBuffer, iFrameSizeList[0] );
  1.3865 +		}
  1.3866 +		else
  1.3867 +		{
  1.3868 +			err = ReadOneCodedPicture(codedBuffer);
  1.3869 +		}
  1.3870 +		//err = ReadOneCodedPicture(codedBuffer);
  1.3871 +
  1.3872 +		TInt pos =0;
  1.3873 +		if ( iInFile.Seek(ESeekStart,pos) )
  1.3874 +		{
  1.3875 +			err = KErrGeneral;
  1.3876 +		}
  1.3877 +
  1.3878 +		if ( iInputEnd )
  1.3879 +		{
  1.3880 +			err = KErrNotFound;
  1.3881 +		}
  1.3882 +
  1.3883 +		if ( err < 0 )
  1.3884 +		{
  1.3885 +			CleanupStack::PopAndDestroy(tempBuff);
  1.3886 +			iInBuffSize = 4*iInBuffSize;
  1.3887 +		}
  1.3888 +	}
  1.3889 +
  1.3890 +
  1.3891 +	// Reitrieve header information from bitstream
  1.3892 +	if ( err  < 0 )
  1.3893 +	{
  1.3894 +		CleanupStack::PopAndDestroy(codedBuffer);
  1.3895 +		PRINT((_L("CVDecTestEngine::ConfigureDecoderL, Reading input data fail")))
  1.3896 +	}
  1.3897 +	else
  1.3898 +	{
  1.3899 +		err = KErrNone;
  1.3900 +
  1.3901 +		headerInfo = iDevvp->GetHeaderInformationL(EDuCodedPicture,EDuElementaryStream,codedBuffer);
  1.3902 +
  1.3903 +		CleanupStack::PopAndDestroy(tempBuff);
  1.3904 +		CleanupStack::PopAndDestroy(codedBuffer);
  1.3905 +
  1.3906 +		//Check Header info
  1.3907 +		if ( headerInfo )
  1.3908 +		{
  1.3909 +
  1.3910 +			PRINT((_L("CVDecTestEngine::ConfigureDecoderL, Configuring the decoder")))
  1.3911 +
  1.3912 +
  1.3913 +			if( iSetPassword )
  1.3914 +			{
  1.3915 +				TBuf16<128> tempBuf;
  1.3916 +				tempBuf.Copy( iPasswordForFLV);
  1.3917 +				PRINT( ( _L( "CVDecTestEngine::ConfigureDecoderL(): password tempBuf: %S." ), &tempBuf ) )
  1.3918 +
  1.3919 +				TPtrC8 metaData((TUint8*)iPasswordForFLV.Ptr(), iPasswordForFLV.Size());
  1.3920 +
  1.3921 +				headerInfo->iOptional = &metaData;
  1.3922 +
  1.3923 +			}
  1.3924 +			iDevvp->ConfigureDecoderL(*headerInfo);
  1.3925 +
  1.3926 +			//return headerInfo
  1.3927 +			iDevvp->ReturnHeader(headerInfo);
  1.3928 +
  1.3929 +		}
  1.3930 +		else
  1.3931 +		{
  1.3932 +			PRINT((_L("CVDecTestEngine::ConfigureDecoderL, Get header info fail")))
  1.3933 +			err = KErrGeneral;
  1.3934 +		}
  1.3935 +
  1.3936 +	}
  1.3937 +
  1.3938 +	// Set size of decoder input buffer
  1.3939 +	if ( iCodecType == EH263 )
  1.3940 +	{
  1.3941 +		if ( (iPictureSize.iWidth <= 176 ) && (iPictureSize.iHeight <= 144) )
  1.3942 +		iInBuffSize = KH263MaxCodedSizeQCIF;
  1.3943 +		else
  1.3944 +		iInBuffSize = KH263MaxCodedSizeCIF;
  1.3945 +
  1.3946 +	}
  1.3947 +	else //Mpeg4 and AVC and FLV
  1.3948 +	{
  1.3949 +		if ( (iPictureSize.iWidth <= 176 ) && (iPictureSize.iHeight <= 144) )
  1.3950 +		iInBuffSize = KMP4MaxCodedSizeQCIF;
  1.3951 +		else if ( (iPictureSize.iWidth <= 352 ) && (iPictureSize.iHeight <= 288) )
  1.3952 +		iInBuffSize = KMP4MaxCodedSizeCIF;
  1.3953 +		else if ( (iPictureSize.iWidth <= 640 ) && (iPictureSize.iHeight <= 480) )
  1.3954 +		iInBuffSize = KMP4MaxCodedSizeVGA;
  1.3955 +		else if  ( (iPictureSize.iWidth <= 720 ) && (iPictureSize.iHeight <= 576) )
  1.3956 +		iInBuffSize = KMP4MaxCodedSizePAL;
  1.3957 +		else
  1.3958 +		iInBuffSize = KMaxCodedSize;
  1.3959 +	}
  1.3960 +
  1.3961 +	AssertTIntEqualL(KErrNone, err);
  1.3962 +
  1.3963 +	TInt pos =0;
  1.3964 +	iSentBuffCount = 0;
  1.3965 +	iReadDataChunk = iDataChunk;
  1.3966 +	iWriteDataChunk = iDataChunk;
  1.3967 +	iDataReadFromFile = 0;
  1.3968 +	iInFile.Seek(ESeekStart,pos);
  1.3969 +
  1.3970 +	PRINT((_L("CVDecTestEngine::ConfigureDecoderL, Out") ))
  1.3971 +}
  1.3972 +
  1.3973 +/* ----------------------------------------------------------------------------
  1.3974 +* Name:       CVDecTestEngine::GetOutputFormatListL()
  1.3975 +* Purpose:
  1.3976 +* Note:
  1.3977 +* Parameters: None
  1.3978 +* Return:     None
  1.3979 +* --------------------------------------------------------------------------*/
  1.3980 +void CVDecTestEngine::GetOutputFormatListL(TInt aHWDevice)
  1.3981 +{
  1.3982 +	PRINT((_L("CVDecTestEngine::GetOutputFormatListL, In") ))
  1.3983 +
  1.3984 +	RArray<TUncompressedVideoFormat> formats;
  1.3985 +	CleanupClosePushL(formats);
  1.3986 +	if (aHWDevice == EPostProcessor)
  1.3987 +	{
  1.3988 +		iDevvp->GetOutputFormatListL(iPostProcId, formats);
  1.3989 +	}
  1.3990 +	else
  1.3991 +	{
  1.3992 +		iDevvp->GetOutputFormatListL(iDecHWDevId, formats);
  1.3993 +	}
  1.3994 +
  1.3995 +	for (TUint i = 0; i < formats.Count(); i++)
  1.3996 +	{
  1.3997 +		PRINT((_L("CVDecTestEngine::GetOutputFormatListL, Format No.%d"), i))
  1.3998 +		PrintUncompressedFormat(formats[i]);
  1.3999 +	}
  1.4000 +	CleanupStack::PopAndDestroy(&formats);
  1.4001 +
  1.4002 +	PRINT((_L("CVDecTestEngine::GetOutputFormatListL, Out") ))
  1.4003 +}
  1.4004 +
  1.4005 +/* ----------------------------------------------------------------------------
  1.4006 +* Name:       CVDecTestEngine::SupportsOutputFormatL()
  1.4007 +* Purpose:
  1.4008 +* Note:
  1.4009 +* Parameters: None
  1.4010 +* Return:     None
  1.4011 +* --------------------------------------------------------------------------*/
  1.4012 +TInt CVDecTestEngine::SupportsOutputFormatL(TInt aHwdev, const TUncompressedVideoFormat& aFormat)
  1.4013 +{
  1.4014 +	PRINT((_L("CVDecTestEngine::SupportsOutputFormatL, In") ))
  1.4015 +
  1.4016 +	TInt result = KErrNotSupported;
  1.4017 +
  1.4018 +	RArray<TUncompressedVideoFormat> formats;
  1.4019 +	CleanupClosePushL(formats);
  1.4020 +	if (aHwdev == EPostProcessor)
  1.4021 +	{
  1.4022 +		iDevvp->GetOutputFormatListL(iPostProcId, formats);
  1.4023 +	}
  1.4024 +	else
  1.4025 +	{
  1.4026 +		iDevvp->GetOutputFormatListL(iDecHWDevId, formats);
  1.4027 +	}
  1.4028 +
  1.4029 +	for (TUint i = 0; i < formats.Count(); i++)
  1.4030 +	{
  1.4031 +		PRINT((_L("CVDecTestEngine::SupportsOutputFormatL, Format No.%d"), i))
  1.4032 +		if (formats[i] == aFormat)
  1.4033 +		{
  1.4034 +			result = KErrNone;
  1.4035 +		}
  1.4036 +		PrintUncompressedFormat(formats[i]);
  1.4037 +	}
  1.4038 +	CleanupStack::PopAndDestroy(&formats);
  1.4039 +
  1.4040 +	PRINT((_L("CVDecTestEngine::SupportsOutputFormatL, Out") ))
  1.4041 +
  1.4042 +	return result;
  1.4043 +}
  1.4044 +
  1.4045 +/* ----------------------------------------------------------------------------
  1.4046 +* Name:       CVDecTestEngine::GetPostProcessorListL()
  1.4047 +* Purpose:
  1.4048 +* Note:
  1.4049 +* Parameters: None
  1.4050 +* Return:     None
  1.4051 +* --------------------------------------------------------------------------*/
  1.4052 +void CVDecTestEngine::GetPostProcessorListL()
  1.4053 +{
  1.4054 +	PRINT((_L("CVDecTestEngine::GetPostProcessorListL, Out") ))
  1.4055 +
  1.4056 +	RArray<TUid> postProcessors;
  1.4057 +	CleanupClosePushL(postProcessors);
  1.4058 +	iDevvp->GetPostProcessorListL(postProcessors);
  1.4059 +	for (TUint i = 0; i < postProcessors.Count(); i++)
  1.4060 +	{
  1.4061 +		PRINT((_L("CVDecTestEngine::GetPostProcessorListL, Uid [%x]"), postProcessors[i].iUid ))
  1.4062 +	}
  1.4063 +	CleanupStack::PopAndDestroy(&postProcessors);
  1.4064 +
  1.4065 +	PRINT((_L("CVDecTestEngine::GetPostProcessorListL, Out") ))
  1.4066 +}
  1.4067 +
  1.4068 +/* ----------------------------------------------------------------------------
  1.4069 +* Name:       CVDecTestEngine::VideoDecoderInfoL()
  1.4070 +* Purpose:
  1.4071 +* Note:
  1.4072 +* Parameters: None
  1.4073 +* Return:     None
  1.4074 +* --------------------------------------------------------------------------*/
  1.4075 +void CVDecTestEngine::VideoDecoderInfoL(TUid aVideoDecoder)
  1.4076 +{
  1.4077 +	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, In") ))
  1.4078 +
  1.4079 +	CVideoDecoderInfo* info;
  1.4080 +	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, 2test") ))
  1.4081 +	info = iDevvp->VideoDecoderInfoLC(aVideoDecoder);
  1.4082 +
  1.4083 +	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, test") ))
  1.4084 +
  1.4085 +	TVersion version = info->Version();
  1.4086 +	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, Manufacturer: %S"), &info->Manufacturer()))
  1.4087 +	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, Identifier: %S"), &info->Identifier()))
  1.4088 +	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, Version information:")))
  1.4089 +	PRINT((_L("Major Version:[%d], Minor Version:[%d], Build number:[%d] "), version.iMajor,version.iMinor,version.iBuild))
  1.4090 +	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, HW Accelerated:[%d]"),info->Accelerated()))
  1.4091 +	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, Support Direct Screen:[%d]"),info->SupportsDirectDisplay()))
  1.4092 +	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, MaxPictureSize, %dx%d"),info->MaxPictureSize().iWidth, info->MaxPictureSize().iHeight))
  1.4093 +	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, MaxBitrate: [%d]"),info->MaxBitrate()))
  1.4094 +	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, SupportsPictureLoss: [%d]"),info->SupportsPictureLoss()))
  1.4095 +	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, SupportsSliceLoss: [%d]"),info->SupportsSliceLoss()))
  1.4096 +	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, CodingStandardSpecificInfo: %S"), &info->CodingStandardSpecificInfo()))
  1.4097 +	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, ImplementationSpecificInfo: %S"), &info->ImplementationSpecificInfo()))
  1.4098 +
  1.4099 +	CleanupStack::PopAndDestroy(info);
  1.4100 +
  1.4101 +	PRINT((_L("CVDecTestEngine::VideoDecoderInfoL, Out") ))
  1.4102 +}
  1.4103 +
  1.4104 +/* ----------------------------------------------------------------------------
  1.4105 +* Name:       CVDecTestEngine::PostProcessorInfoL()
  1.4106 +* Purpose:
  1.4107 +* Note:
  1.4108 +* Parameters: None
  1.4109 +* Return:     None
  1.4110 +* --------------------------------------------------------------------------*/
  1.4111 +void CVDecTestEngine::PostProcessorInfoL(TUid aPostProcessor)
  1.4112 +{
  1.4113 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, In") ))
  1.4114 +
  1.4115 +	CPostProcessorInfo* info;
  1.4116 +	info = iDevvp->PostProcessorInfoLC(aPostProcessor);
  1.4117 +
  1.4118 +	TVersion version = info->Version();
  1.4119 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Manufacturer: %S"), &info->Manufacturer()))
  1.4120 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Identifier: %S"), &info->Identifier()))
  1.4121 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Version information:")))
  1.4122 +	PRINT((_L("Major Version:[%d], Minor Version:[%d], Build number:[%d] "), version.iMajor,version.iMinor,version.iBuild))
  1.4123 +
  1.4124 +	// combination
  1.4125 +	RArray<TUint32> combination = info->SupportedCombinations();
  1.4126 +
  1.4127 +	for (TInt i=0; i < combination.Count(); i++)
  1.4128 +	{
  1.4129 +		PRINT((_L("CVDecTestEngine::PostProcessorInfoL, combiantion:[%x]"), combination.operator[](i)))
  1.4130 +	}
  1.4131 +
  1.4132 +	//Color Conversion YUV to RGV
  1.4133 +	TYuvToRgbCapabilities colorconv;
  1.4134 +	colorconv = info->YuvToRgbCapabilities();
  1.4135 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, YUV Sampling Pattern bit:[0x%x]"),colorconv.iSamplingPatterns))
  1.4136 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, YUV Coefficient bit:[0x%x]"),colorconv.iCoefficients))
  1.4137 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, RGB Formats bit:[0x%x]"),colorconv.iRgbFormats))
  1.4138 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Lightness Control:[%d]"),colorconv.iLightnessControl))
  1.4139 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Saturation Control:[%d]"),colorconv.iSaturationControl))
  1.4140 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Contrast Control:[%d]"),colorconv.iContrastControl))
  1.4141 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Gamma Correction:[%d]"),colorconv.iGammaCorrection))
  1.4142 +
  1.4143 +	if(colorconv.iDitherTypes  & EDitherNone)
  1.4144 +	{
  1.4145 +		PRINT((_L("CVDecTestEngine::PostProcessorInfoL, No dither support")))
  1.4146 +	}
  1.4147 +	if(colorconv.iDitherTypes  & EDitherOrdered)
  1.4148 +	{
  1.4149 +		PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Ordered Dither")))
  1.4150 +	}
  1.4151 +	if(colorconv.iDitherTypes  & EDitherErrorDiffusion)
  1.4152 +	{
  1.4153 +		PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Error diffusion dither")))
  1.4154 +	}
  1.4155 +	if(colorconv.iDitherTypes  & EDitherOther)
  1.4156 +	{
  1.4157 +		PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Other hardware device specific dithering type")))
  1.4158 +	}
  1.4159 +
  1.4160 +
  1.4161 +	//HW Accelated
  1.4162 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, HW Accelerated:[%d]"),info->Accelerated()))
  1.4163 +
  1.4164 +	//Support Direct Screen
  1.4165 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Direct Screen:[%d]"),info->SupportsDirectDisplay()))
  1.4166 +
  1.4167 +	//Rotation
  1.4168 +	TUint rotation;
  1.4169 +	rotation =  info->SupportedRotations();
  1.4170 +
  1.4171 +	if(rotation & 0x00000001)
  1.4172 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Rotation: 90Clockwise ")))
  1.4173 +	if(rotation & 0x00000002)
  1.4174 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Rotation: 90Anticlockwise ")))
  1.4175 +	if(rotation & 0x00000004)
  1.4176 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Rotation: 180 ")))
  1.4177 +	if(!(rotation & 0x00000007))
  1.4178 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, No Rotation supported ")))
  1.4179 +
  1.4180 +	//Arbitrary Scaling
  1.4181 +	TInt support = info->SupportsArbitraryScaling();
  1.4182 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Arbitrary Scaling:[%d]"),support))
  1.4183 +
  1.4184 +	//Scalling Factor
  1.4185 +	if ( support )
  1.4186 +	{
  1.4187 +		RArray<TScaleFactor> scale = info->SupportedScaleFactors();
  1.4188 +
  1.4189 +		for (TInt i=0; i<scale.Count(); i++)
  1.4190 +		{
  1.4191 +			PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Scalling Factor:[%d]/[%d]"),scale.operator[](i).iScaleNum, scale.operator[](i).iScaleDenom))
  1.4192 +		}
  1.4193 +	}
  1.4194 +
  1.4195 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Support Anti Aliased filter:[%d]"),info->AntiAliasedScaling()))
  1.4196 +
  1.4197 +	CleanupStack::PopAndDestroy(info);
  1.4198 +
  1.4199 +	PRINT((_L("CVDecTestEngine::PostProcessorInfoL, Out") ))
  1.4200 +}
  1.4201 +
  1.4202 +/* ----------------------------------------------------------------------------
  1.4203 +* Name:       CVDecTestEngine::SupportsFormatL()
  1.4204 +* Purpose:    Retrieves information about an installed video decoder
  1.4205 +* Parameters: None
  1.4206 +* Return:     None
  1.4207 +* --------------------------------------------------------------------------*/
  1.4208 +
  1.4209 +TInt CVDecTestEngine::SupportsFormatL(const TUid& aUid, const CCompressedVideoFormat& aFormat)
  1.4210 +{
  1.4211 +	PRINT((_L("CVDecTestEngine::SupportsFormatL(),In")))
  1.4212 +
  1.4213 +	TInt supports = KErrNotSupported;
  1.4214 +
  1.4215 +	CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  1.4216 +	if(!info)
  1.4217 +	{
  1.4218 +		PRINT((_L("CVDecTestEngine::SupportsFormatL(),Error")))
  1.4219 +		return KErrGeneral;
  1.4220 +	}
  1.4221 +
  1.4222 +	if (info->SupportsFormat(aFormat))
  1.4223 +	{
  1.4224 +		PRINT((_L("CVDecTestEngine::SupportsFormatL, Supported format found")))
  1.4225 +		supports=KErrNone;
  1.4226 +	}
  1.4227 +
  1.4228 +	CleanupStack::PopAndDestroy();
  1.4229 +
  1.4230 +	PRINT((_L("CVDecTestEngine::SupportsFormatL(),Out")))
  1.4231 +	return supports;
  1.4232 +}
  1.4233 +
  1.4234 +
  1.4235 +/* ----------------------------------------------------------------------------
  1.4236 +* Name:       CVDecTestEngine::SupportsFormatInfoL()
  1.4237 +* Purpose:    Retrieves information about an installed video decoder
  1.4238 +* Parameters: None
  1.4239 +* Return:     None
  1.4240 +* --------------------------------------------------------------------------*/
  1.4241 +
  1.4242 +TInt CVDecTestEngine::SupportsFormatInfoL(const TUid& aUid, const CCompressedVideoFormat& aFormat)
  1.4243 +{
  1.4244 +	PRINT((_L("CVDecTestEngine::SupportsFormatInfoL(),In")))
  1.4245 +
  1.4246 +	TInt supports = KErrNotSupported;
  1.4247 +	RPointerArray<CCompressedVideoFormat> formats;
  1.4248 +
  1.4249 +	CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  1.4250 +	if(!info)
  1.4251 +	{
  1.4252 +		PRINT((_L("CVDecTestEngine::SupportsFormatInfoL(),Error")))
  1.4253 +		formats.Close();
  1.4254 +		return KErrGeneral;
  1.4255 +	}
  1.4256 +
  1.4257 +	formats = info->SupportedFormats();
  1.4258 +
  1.4259 +	PRINT((_L("CVDecTestEngine::SupportsFormatInfoL(), supported formats")))
  1.4260 +
  1.4261 +	for (TUint i = 0; i < formats.Count(); i++)
  1.4262 +	{
  1.4263 +		TBuf16<128> format;
  1.4264 +		format.Copy(formats[i]->MimeType());
  1.4265 +		PRINT((_L("CVDecTestEngine::SupportsFormatInfoL, Format [%S]"), &format))
  1.4266 +		//PRINT((_L("CVDecTestEngine::SupportsFormatInfoL, %d. Format [%S]"), &(formats[i]))
  1.4267 +		if (*(formats[i]) == aFormat)
  1.4268 +		{
  1.4269 +			supports = KErrNone;
  1.4270 +			PRINT((_L("CVDecTestEngine::SupportsFormatInfoL, Supported format found")))
  1.4271 +		}
  1.4272 +	}
  1.4273 +
  1.4274 +	CleanupStack::PopAndDestroy();
  1.4275 +
  1.4276 +	PRINT((_L("CVDecTestEngine::SupportsFormatInfoL(),Out")))
  1.4277 +	return supports;
  1.4278 +}
  1.4279 +
  1.4280 +/* ----------------------------------------------------------------------------
  1.4281 +* Name:       CVDecTestEngine::SupportsAccelerationL()
  1.4282 +* Purpose:    Retrieves information about an installed video decoder
  1.4283 +* Parameters: None
  1.4284 +* Return:     None
  1.4285 +* --------------------------------------------------------------------------*/
  1.4286 +
  1.4287 +TInt CVDecTestEngine::SupportsAccelerationL(TInt aHwDev, const TUid& aUid)
  1.4288 +{
  1.4289 +	PRINT((_L("CVDecTestEngine::SupportsAccelerationL(),In")))
  1.4290 +
  1.4291 +	TInt supports = KErrNotSupported;
  1.4292 +	TBool supported = EFalse;
  1.4293 +
  1.4294 +	if (aHwDev == EPostProcessor)
  1.4295 +	{
  1.4296 +		CPostProcessorInfo* info = iDevvp->PostProcessorInfoLC(aUid);
  1.4297 +		if(!info)
  1.4298 +		{
  1.4299 +			PRINT((_L("CVDecTestEngine::SupportsAccelerationL(),Error")))
  1.4300 +			return KErrGeneral;
  1.4301 +		}
  1.4302 +		supported = info->Accelerated();
  1.4303 +	}
  1.4304 +	else
  1.4305 +	{
  1.4306 +		CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  1.4307 +		if(!info)
  1.4308 +		{
  1.4309 +			PRINT((_L("CVDecTestEngine::SupportsAccelerationL(),Error")))
  1.4310 +			return KErrGeneral;
  1.4311 +		}
  1.4312 +
  1.4313 +		supported = info->Accelerated();
  1.4314 +	}
  1.4315 +
  1.4316 +	if (supported)
  1.4317 +	{
  1.4318 +		supports = KErrNone;
  1.4319 +	}
  1.4320 +
  1.4321 +	CleanupStack::PopAndDestroy();
  1.4322 +
  1.4323 +	PRINT((_L("CVDecTestEngine::SupportsAccelerationL(),Out")))
  1.4324 +	return supports;
  1.4325 +}
  1.4326 +
  1.4327 +/* ----------------------------------------------------------------------------
  1.4328 +* Name:       CVDecTestEngine::SupportsDirectDisplayL()
  1.4329 +* Purpose:    Retrieves information about an installed video decoder
  1.4330 +* Parameters: None
  1.4331 +* Return:     None
  1.4332 +* --------------------------------------------------------------------------*/
  1.4333 +
  1.4334 +TInt CVDecTestEngine::SupportsDirectDisplayL(TInt aHwDev, const TUid& aUid)
  1.4335 +{
  1.4336 +	PRINT((_L("CVDecTestEngine::SupportsDirectDisplayL(),In")))
  1.4337 +
  1.4338 +	TInt supports = KErrNotSupported;
  1.4339 +	TBool supported = EFalse;
  1.4340 +
  1.4341 +	if (aHwDev == EPostProcessor)
  1.4342 +	{
  1.4343 +		CPostProcessorInfo* info = iDevvp->PostProcessorInfoLC(aUid);
  1.4344 +		if(!info)
  1.4345 +		{
  1.4346 +			PRINT((_L("CVDecTestEngine::SupportsDirectDisplayL(),Error")))
  1.4347 +			return KErrGeneral;
  1.4348 +		}
  1.4349 +
  1.4350 +		supported = info->SupportsDirectDisplay();
  1.4351 +	}
  1.4352 +	else
  1.4353 +	{
  1.4354 +		CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  1.4355 +		if(!info)
  1.4356 +		{
  1.4357 +			PRINT((_L("CVDecTestEngine::SupportsDirectDisplayL(),Error")))
  1.4358 +			return KErrGeneral;
  1.4359 +		}
  1.4360 +
  1.4361 +		supported = info->SupportsDirectDisplay();
  1.4362 +	}
  1.4363 +
  1.4364 +	if (supported)
  1.4365 +	{
  1.4366 +		supports = KErrNone;
  1.4367 +	}
  1.4368 +
  1.4369 +	CleanupStack::PopAndDestroy();
  1.4370 +
  1.4371 +	PRINT((_L("CVDecTestEngine::SupportsDirectDisplayL(),Out")))
  1.4372 +	return supports;
  1.4373 +}
  1.4374 +
  1.4375 +
  1.4376 +/* ----------------------------------------------------------------------------
  1.4377 +* Name:       CVDecTestEngine::SupportsMaxPictureSizeL()
  1.4378 +* Purpose:    Retrieves information about an installed video decoder
  1.4379 +* Parameters: None
  1.4380 +* Return:     None
  1.4381 +* --------------------------------------------------------------------------*/
  1.4382 +
  1.4383 +TInt CVDecTestEngine::SupportsMaxPictureSizeL(const TUid& aUid, TSize aSize)
  1.4384 +{
  1.4385 +	PRINT((_L("CVDecTestEngine::SupportsMaxPictureSizeL(),In")))
  1.4386 +
  1.4387 +	TInt supports = KErrNotSupported;
  1.4388 +
  1.4389 +	CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  1.4390 +	if(!info)
  1.4391 +	{
  1.4392 +		PRINT((_L("CVDecTestEngine::SupportsMaxPictureSizeL(),Error")))
  1.4393 +		return KErrGeneral;
  1.4394 +	}
  1.4395 +
  1.4396 +	TSize size = info->MaxPictureSize();
  1.4397 +
  1.4398 +	if (size.iWidth >= aSize.iWidth && size.iHeight >= aSize.iHeight)
  1.4399 +	{
  1.4400 +		supports = KErrNone;
  1.4401 +	}
  1.4402 +
  1.4403 +	CleanupStack::PopAndDestroy();
  1.4404 +
  1.4405 +	PRINT((_L("CVDecTestEngine::SupportsMaxPictureSizeL(),Out")))
  1.4406 +	return supports;
  1.4407 +}
  1.4408 +
  1.4409 +/* ----------------------------------------------------------------------------
  1.4410 +* Name:       CVDecTestEngine::SupportsMaxPictureRateL()
  1.4411 +* Purpose:    Retrieves information about an installed video decoder
  1.4412 +* Parameters: None
  1.4413 +* Return:     None
  1.4414 +* --------------------------------------------------------------------------*/
  1.4415 +
  1.4416 +TInt CVDecTestEngine::SupportsMaxPictureRateL(const TUid& aUid, TPictureRateAndSize& aRateAndSize)
  1.4417 +{
  1.4418 +	PRINT((_L("CVDecTestEngine::SupportsMaxPictureRateL(),In")))
  1.4419 +
  1.4420 +	TInt supports = KErrNotSupported;
  1.4421 +	TPictureRateAndSize picRateAndSize;
  1.4422 +
  1.4423 +	CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  1.4424 +	if(!info)
  1.4425 +	{
  1.4426 +		PRINT((_L("CVEncTestEngine::SupportsMaxPictureRateL(),Error")))
  1.4427 +		return KErrGeneral;
  1.4428 +	}
  1.4429 +
  1.4430 +	RArray<TPictureRateAndSize> picRateAndSizeArray = info->MaxPictureRates();
  1.4431 +
  1.4432 +	for (TUint i=0; i < picRateAndSizeArray.Count(); i++)
  1.4433 +	{
  1.4434 +		picRateAndSize = picRateAndSizeArray[i];
  1.4435 +		if (aRateAndSize.iPictureRate <= picRateAndSize.iPictureRate && aRateAndSize.iPictureSize.iWidth <= picRateAndSize.iPictureSize.iWidth &&
  1.4436 +		aRateAndSize.iPictureSize.iHeight <= picRateAndSize.iPictureSize.iHeight)
  1.4437 +		{
  1.4438 +			supports = KErrNone;
  1.4439 +		}
  1.4440 +	}
  1.4441 +
  1.4442 +	CleanupStack::PopAndDestroy();
  1.4443 +
  1.4444 +	PRINT((_L("CVDecTestEngine::SupportsMaxPictureRateL(),Out")))
  1.4445 +	return supports;
  1.4446 +}
  1.4447 +
  1.4448 +
  1.4449 +/* ----------------------------------------------------------------------------
  1.4450 +* Name:       CVDecTestEngine::SupportsSliceLossL()
  1.4451 +* Purpose:    Retrieves information about an installed video decoder
  1.4452 +* Parameters: None
  1.4453 +* Return:     None
  1.4454 +* --------------------------------------------------------------------------*/
  1.4455 +
  1.4456 +TInt CVDecTestEngine::SupportsSliceLossL(const TUid& aUid)
  1.4457 +{
  1.4458 +	PRINT((_L("CVDecTestEngine::SupportsSliceLossL(),In")))
  1.4459 +
  1.4460 +	TInt supports = KErrNotSupported;
  1.4461 +	TBool supported = EFalse;
  1.4462 +
  1.4463 +	CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  1.4464 +	if(!info)
  1.4465 +	{
  1.4466 +		PRINT((_L("CVDecTestEngine::SupportsSliceLossL(),Error")))
  1.4467 +		return KErrGeneral;
  1.4468 +	}
  1.4469 +
  1.4470 +	supported = info->SupportsSliceLoss();
  1.4471 +
  1.4472 +	if (supported)
  1.4473 +	{
  1.4474 +		supports = KErrNone;
  1.4475 +	}
  1.4476 +
  1.4477 +	CleanupStack::PopAndDestroy();
  1.4478 +
  1.4479 +	PRINT((_L("CVDecTestEngine::SupportsSliceLossL(),Out")))
  1.4480 +	return supports;
  1.4481 +}
  1.4482 +
  1.4483 +/* ----------------------------------------------------------------------------
  1.4484 +* Name:       CVDecTestEngine::SupportsPictureLossL()
  1.4485 +* Purpose:    Retrieves information about an installed video decoder
  1.4486 +* Parameters: None
  1.4487 +* Return:     None
  1.4488 +* --------------------------------------------------------------------------*/
  1.4489 +
  1.4490 +TInt CVDecTestEngine::SupportsPictureLossL(const TUid& aUid)
  1.4491 +{
  1.4492 +	PRINT((_L("CVDecTestEngine::SupportsPictureLossL(),In")))
  1.4493 +
  1.4494 +	TInt supports = KErrNotSupported;
  1.4495 +	TBool supported = EFalse;
  1.4496 +
  1.4497 +	CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  1.4498 +	if(!info)
  1.4499 +	{
  1.4500 +		PRINT((_L("CVDecTestEngine::SupportsPictureLossL(),Error")))
  1.4501 +		return KErrGeneral;
  1.4502 +	}
  1.4503 +
  1.4504 +	supported = info->SupportsPictureLoss();
  1.4505 +
  1.4506 +	if (supported)
  1.4507 +	{
  1.4508 +		supports = KErrNone;
  1.4509 +	}
  1.4510 +
  1.4511 +	CleanupStack::PopAndDestroy();
  1.4512 +
  1.4513 +	PRINT((_L("CVDecTestEngine::SupportsPictureLossL(),Out")))
  1.4514 +	return supports;
  1.4515 +}
  1.4516 +
  1.4517 +
  1.4518 +/* ----------------------------------------------------------------------------
  1.4519 +* Name:       CVDecTestEngine::SupportsMaxBitrateL()
  1.4520 +* Purpose:    Retrieves information about an installed video encoder
  1.4521 +* Parameters: None
  1.4522 +* Return:     None
  1.4523 +* --------------------------------------------------------------------------*/
  1.4524 +
  1.4525 +TInt CVDecTestEngine::SupportsMaxBitrateL(const TUid& aUid, TInt aBitrate)
  1.4526 +{
  1.4527 +	PRINT((_L("CVDecTestEngine::SupportsMaxBitrateL(),In")))
  1.4528 +
  1.4529 +	TInt supports = KErrNotSupported;
  1.4530 +	TInt bitrate = 0;
  1.4531 +
  1.4532 +	CVideoDecoderInfo* info = iDevvp->VideoDecoderInfoLC(aUid);
  1.4533 +	if(!info)
  1.4534 +	{
  1.4535 +		PRINT((_L("CVDecTestEngine::SupportsMaxBitrateL(),Error")))
  1.4536 +		return KErrGeneral;
  1.4537 +	}
  1.4538 +
  1.4539 +	bitrate = info->MaxBitrate();
  1.4540 +
  1.4541 +	if (aBitrate <= bitrate)
  1.4542 +	{
  1.4543 +		supports = KErrNone;
  1.4544 +	}
  1.4545 +
  1.4546 +	CleanupStack::PopAndDestroy();
  1.4547 +
  1.4548 +	PRINT((_L("CVDecTestEngine::SupportsMaxBitrateL(),Out")))
  1.4549 +	return supports;
  1.4550 +}
  1.4551 +
  1.4552 +
  1.4553 +/* ----------------------------------------------------------------------------
  1.4554 +* Name:       CVDecTestEngine::SetYuvToRgbOptionsL()
  1.4555 +* Purpose:
  1.4556 +* Note:
  1.4557 +* Parameters: None
  1.4558 +* Return:     None
  1.4559 +* --------------------------------------------------------------------------*/
  1.4560 +void CVDecTestEngine::SetYuvToRgbOptionsL(TInt aHWDevice, const TYuvToRgbOptions& aOptions, const TYuvFormat& aYuvFormat, TRgbFormat aRgbFormat)
  1.4561 +{
  1.4562 +	PRINT((_L("CVDecTestEngine::SetYuvToRgbOptionsL, In") ))
  1.4563 +
  1.4564 +	if (aHWDevice == EPostProcessor)
  1.4565 +	{
  1.4566 +		iDevvp->SetYuvToRgbOptionsL(iPostProcId, aOptions, aYuvFormat, aRgbFormat);
  1.4567 +	}
  1.4568 +	else
  1.4569 +	{
  1.4570 +		iDevvp->SetYuvToRgbOptionsL(iDecHWDevId, aOptions, aYuvFormat, aRgbFormat);
  1.4571 +	}
  1.4572 +
  1.4573 +	PRINT((_L("CVDecTestEngine::SetYuvToRgbOptionsL, Out") ))
  1.4574 +}
  1.4575 +
  1.4576 +/* ----------------------------------------------------------------------------
  1.4577 +* Name:       CVDecTestEngine::SetSlowClient()
  1.4578 +* Purpose:
  1.4579 +* Note:
  1.4580 +* Parameters: None
  1.4581 +* Return:     None
  1.4582 +* --------------------------------------------------------------------------*/
  1.4583 +void CVDecTestEngine::SetSlowClient(TBool aOption)
  1.4584 +{
  1.4585 +	PRINT((_L("CVDecTestEngine::SetSlowClient, In") ))
  1.4586 +
  1.4587 +	iSetSlowClient = aOption;
  1.4588 +
  1.4589 +	PRINT((_L("CVDecTestEngine::SetSlowClient, Out") ))
  1.4590 +}
  1.4591 +
  1.4592 +/* ----------------------------------------------------------------------------
  1.4593 +* Name:       CVDecTestEngine::SetFastClient()
  1.4594 +* Purpose:
  1.4595 +* Note:
  1.4596 +* Parameters: None
  1.4597 +* Return:     None
  1.4598 +* --------------------------------------------------------------------------*/
  1.4599 +void CVDecTestEngine::SetFastClient(TBool aOption)
  1.4600 +{
  1.4601 +	PRINT((_L("CVDecTestEngine::SetFastClient, In") ))
  1.4602 +
  1.4603 +	iSetFastClient = aOption;
  1.4604 +
  1.4605 +	PRINT((_L("CVDecTestEngine::SetFastClient, Out") ))
  1.4606 +}
  1.4607 +
  1.4608 +/* ----------------------------------------------------------------------------
  1.4609 +* Name:       CVDecTestEngine::SetAUFormat()
  1.4610 +* Purpose:
  1.4611 +* Note:
  1.4612 +* Parameters: None
  1.4613 +* Return:     None
  1.4614 +* --------------------------------------------------------------------------*/
  1.4615 +TInt CVDecTestEngine::SetAUFormat()
  1.4616 +{
  1.4617 +	PRINT((_L("CVDecTestEngine::SetAUFormat, In") ))
  1.4618 +
  1.4619 +	if (iCodecType== EAVC)
  1.4620 +	{
  1.4621 +		iSetAUFormat = ETrue;
  1.4622 +
  1.4623 +	}
  1.4624 +	else
  1.4625 +	{
  1.4626 +		return KErrNotSupported;
  1.4627 +	}
  1.4628 +
  1.4629 +	PRINT((_L("CVDecTestEngine::SetAUFormat, Out") ))
  1.4630 +
  1.4631 +	return KErrNone;
  1.4632 +}
  1.4633 +
  1.4634 +/* ----------------------------------------------------------------------------
  1.4635 +* Name:       CVDecTestEngine::MoveFileL()
  1.4636 +* Purpose:
  1.4637 +* Note:
  1.4638 +* Parameters: None
  1.4639 +* Return:     None
  1.4640 +* --------------------------------------------------------------------------*/
  1.4641 +TInt CVDecTestEngine::MoveFileL(const TDesC &anOld, const TDesC &aNew)
  1.4642 +{
  1.4643 +	PRINT((_L("CVDecTestEngine::MoveFileL, In") ))
  1.4644 +
  1.4645 +	CFileMan* fileman = CFileMan::NewL(iFs);
  1.4646 +	iMemAlloc++;
  1.4647 +	#ifdef __MEM_CHECK_
  1.4648 +	PRINT((_L("CVDecTestEngine::MoveFileL, mem alloc, fileman") ))
  1.4649 +	#endif
  1.4650 +	PRINT((_L("CVDecTestEngine::MoveFileL, fileman [%x]"), fileman))
  1.4651 +
  1.4652 +	CloseFile();
  1.4653 +
  1.4654 +	PRINT((_L("CVDecTestEngine::MoveFileL, File [%s] moving to [%s]"), &anOld, &aNew ))
  1.4655 +	fileman->Move(anOld, aNew);
  1.4656 +
  1.4657 +	PRINT((_L("CVDecTestEngine::MoveFileL, File [%s] moved to [%s]"), &anOld, &aNew ))
  1.4658 +
  1.4659 +	delete fileman;
  1.4660 +	iMemDelete++;
  1.4661 +	#ifdef __MEM_CHECK_
  1.4662 +	PRINT((_L("CVDecTestEngine::MoveFileL, mem del, fileman") ))
  1.4663 +	#endif
  1.4664 +	PRINT((_L("CVDecTestEngine::MoveFileL, Out") ))
  1.4665 +
  1.4666 +	return KErrNone;
  1.4667 +}
  1.4668 +
  1.4669 +/* ----------------------------------------------------------------------------
  1.4670 +* Name:       CVDecTestEngine::CopyFileL()
  1.4671 +* Purpose:
  1.4672 +* Note:
  1.4673 +* Parameters: None
  1.4674 +* Return:     None
  1.4675 +* --------------------------------------------------------------------------*/
  1.4676 +TInt CVDecTestEngine::CopyFileL(const TDesC &anOld, const TDesC &aNew)
  1.4677 +{
  1.4678 +	PRINT((_L("CVDecTestEngine::CopyFileL, In") ))
  1.4679 +
  1.4680 +	CFileMan* fileman = CFileMan::NewL(iFs);
  1.4681 +	iMemAlloc++;
  1.4682 +	#ifdef __MEM_CHECK_
  1.4683 +	PRINT((_L("CVDecTestEngine::MoveFileL, mem alloc, fileman") ))
  1.4684 +	#endif
  1.4685 +	PRINT((_L("CVDecTestEngine::CopyFileL, fileman [%x]"), fileman))
  1.4686 +
  1.4687 +	//CloseFile();
  1.4688 +
  1.4689 +	PRINT((_L("CVDecTestEngine::CopyFileL, File [%s] copying to [%s]"), &anOld, &aNew ))
  1.4690 +	fileman->Copy(anOld, aNew);
  1.4691 +
  1.4692 +	PRINT((_L("CVDecTestEngine::CopyFileL, File [%s] copied to [%s]"), &anOld, &aNew ))
  1.4693 +
  1.4694 +	delete fileman;
  1.4695 +	iMemDelete++;
  1.4696 +	#ifdef __MEM_CHECK_
  1.4697 +	PRINT((_L("CVDecTestEngine::CopyFileL, mem del, fileman") ))
  1.4698 +	#endif
  1.4699 +	PRINT((_L("CVDecTestEngine::CopyFileL, Out") ))
  1.4700 +
  1.4701 +	return KErrNone;
  1.4702 +}
  1.4703 +
  1.4704 +/* ----------------------------------------------------------------------------
  1.4705 +* Name:       CVDecTestEngine::HandleNewBufferL()
  1.4706 +* Purpose:    Get Next input data
  1.4707 +* Note:
  1.4708 +* Parameters: None
  1.4709 +* Return:     None
  1.4710 +* --------------------------------------------------------------------------*/
  1.4711 +
  1.4712 +
  1.4713 +void CVDecTestEngine::HandleNewBufferL()
  1.4714 +{
  1.4715 +
  1.4716 +	if ( iState == ERunning && !iInputEnd )
  1.4717 +	{
  1.4718 +		if ( iDecHWDevId || iCIBuffMgmtOn ) //Retrieve buffer from Hwdevice
  1.4719 +		{
  1.4720 +			GetInputBufferL();
  1.4721 +		}
  1.4722 +		else
  1.4723 +		{
  1.4724 +			FillAndSendBufferL();   // Postproc input
  1.4725 +		}
  1.4726 +
  1.4727 +	}
  1.4728 +	else
  1.4729 +	{
  1.4730 +		PRINT((_L("CVDecTestEngine::HandleNewBufferL, inputEnd found") ))
  1.4731 +		if (iLastFrame)
  1.4732 +		{
  1.4733 +			PRINT((_L("CVDecTestEngine::HandleNewBufferL, Getting last input buffer") ))
  1.4734 +			GetInputBufferL();
  1.4735 +		}
  1.4736 +	}
  1.4737 +
  1.4738 +}
  1.4739 +
  1.4740 +/* ----------------------------------------------------------------------------
  1.4741 +* Name:       CVDecTestEngine::LoadNextFrameL()
  1.4742 +* Purpose:
  1.4743 +* Note:
  1.4744 +* Parameters: None
  1.4745 +* Return:     None
  1.4746 +* --------------------------------------------------------------------------*/
  1.4747 +
  1.4748 +TInt CVDecTestEngine::LoadNextFrameL(TVideoInputBuffer* aCodedInBuffer)
  1.4749 +{
  1.4750 +	// Normal VC1 video reading
  1.4751 +	// Read file after the file header
  1.4752 +	PRINT((_L("CVDecTestEngine::LoadNextFrameL, In")));
  1.4753 +	unsigned int frameDataSize = 4;     //4 Bytes to obain the framesize
  1.4754 +	unsigned int frameSize=0;
  1.4755 +	unsigned int Timestamp;
  1.4756 +	TInt err = 0;
  1.4757 +	TUint8* ptr = new (ELeave) TUint8[frameDataSize]; // dynamic alloc 1
  1.4758 +	iMemAlloc++;
  1.4759 +	#ifdef __MEM_CHECK_
  1.4760 +	PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem alloc, ptr") ))
  1.4761 +	#endif
  1.4762 +	TPtr8 frameData(ptr, frameDataSize);
  1.4763 +	if ( (err = iInFile.Read(frameData, frameDataSize)) != KErrNone)
  1.4764 +	{
  1.4765 +		PRINT((_L("CVDecTestEngine::LoadNextFrameL, Error reading file") ))
  1.4766 +		delete ptr;
  1.4767 +		ptr = NULL;
  1.4768 +		iMemDelete++;
  1.4769 +		#ifdef __MEM_CHECK_
  1.4770 +		PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem del, ptr") ))
  1.4771 +		#endif
  1.4772 +
  1.4773 +		return err;
  1.4774 +	}
  1.4775 +
  1.4776 +	if (frameData.Length() < 4)
  1.4777 +	{
  1.4778 +		PRINT((_L("CVDecTestEngine::LoadNextFrameL, File end found") ))
  1.4779 +		aCodedInBuffer->iData.SetLength( 0 );
  1.4780 +		iInputEnd = ETrue;
  1.4781 +		delete ptr;
  1.4782 +		ptr = NULL;
  1.4783 +		iMemDelete++;
  1.4784 +		#ifdef __MEM_CHECK_
  1.4785 +		PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem del, ptr") ))
  1.4786 +		#endif
  1.4787 +		return KErrNone;
  1.4788 +	}
  1.4789 +
  1.4790 +	PRINT((_L("CVDecTestEngine::LoadNextFrameL, Reading Item") ))
  1.4791 +	ReadItemLE(ptr, 4, (TUint8 *)&frameSize);
  1.4792 +	PRINT((_L("CVDecTestEngine::LoadNextFrameL, before AND frameSize: %x"), frameSize ))
  1.4793 +
  1.4794 +	if (frameData.Length() < 4)
  1.4795 +	{
  1.4796 +		PRINT((_L("CVDecTestEngine::LoadNextFrameL, File end found") ))
  1.4797 +		iInputEnd = ETrue;
  1.4798 +		delete ptr;
  1.4799 +		ptr = NULL;
  1.4800 +		iMemDelete++;
  1.4801 +		#ifdef __MEM_CHECK_
  1.4802 +		PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem del, ptr") ))
  1.4803 +		#endif
  1.4804 +		return KErrNone;
  1.4805 +	}
  1.4806 +
  1.4807 +	//RCV_V2_FRAMESIZE_FLAGS
  1.4808 +	frameSize = frameSize & ~(0xff000000);
  1.4809 +
  1.4810 +	PRINT((_L("CVDecTestEngine::LoadNextFrameL, frameSize: %d"), frameSize ))
  1.4811 +
  1.4812 +	//Now obtain the Timestamp of the frame
  1.4813 +	if ( (err = iInFile.Read(frameData, frameDataSize)) != KErrNone)
  1.4814 +	{
  1.4815 +		PRINT((_L("CVDecTestEngine::LoadNextFrameL, Error reading file %d"), err ))
  1.4816 +		return err;
  1.4817 +	}
  1.4818 +
  1.4819 +	PRINT((_L("CVDecTestEngine::LoadNextFrameL, Reading Item2") ))
  1.4820 +	ReadItemLE(ptr, 4, (TUint8 *)&Timestamp);
  1.4821 +	PRINT((_L("CVDecTestEngine::LoadNextFrameL, Timestamp: %d"), Timestamp ))
  1.4822 +
  1.4823 +	delete ptr;
  1.4824 +	ptr = NULL;
  1.4825 +	iMemDelete++;
  1.4826 +	#ifdef __MEM_CHECK_
  1.4827 +	PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem del, ptr") ))
  1.4828 +	#endif
  1.4829 +
  1.4830 +	if (frameSize != 0)
  1.4831 +	{
  1.4832 +
  1.4833 +		tempFrame += frameSize + 8;
  1.4834 +		PRINT((_L("CVDecTestEngine::LoadNextFrameL, tota data %d"), tempFrame ))
  1.4835 +		PRINT((_L("CVDecTestEngine::LoadNextFrameL, frame"), iFrame))
  1.4836 +
  1.4837 +		TInt currentPos = 0;
  1.4838 +		iInFile.Seek(ESeekCurrent, currentPos );
  1.4839 +		PRINT((_L("CVDecTestEngine::LoadNextFrameL, currentPos %d"), currentPos ))
  1.4840 +		currentPos = 0;
  1.4841 +
  1.4842 +		//Send metadata in the first frame
  1.4843 +		if (iFrame==0)
  1.4844 +		{
  1.4845 +			TInt pos = 0;
  1.4846 +			//err = iInFile.Seek(ESeekCurrent,pos);
  1.4847 +			err = iInFile.Seek(ESeekStart,pos);
  1.4848 +			//        	pos -= 44; //header (36) and framesize+timestamp (8)
  1.4849 +			//        	err = iInFile.Seek(ESeekCurrent,pos);
  1.4850 +			PRINT((_L("CVDecTestEngine::LoadNextFrameL, first frame")))
  1.4851 +			if ( (err = iInFile.Read(aCodedInBuffer->iData, frameSize+44)) != KErrNone)
  1.4852 +			{
  1.4853 +				PRINT((_L("CVDecTestEngine::LoadNextFrameL, Error reading file %d"), err ))
  1.4854 +				return err;
  1.4855 +			}
  1.4856 +
  1.4857 +			TUint8* ptr2 = new(ELeave)TUint8[4];       // dynamic alloc 2
  1.4858 +			iMemAlloc++;
  1.4859 +			#ifdef __MEM_CHECK_
  1.4860 +			PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem alloc, ptr2") ))
  1.4861 +			#endif
  1.4862 +			Mem::FillZ(ptr2,4);
  1.4863 +			TPtr8 firstPtr(ptr2,4,4);
  1.4864 +			//			aCodedInBuffer->iData.Insert(35,firstPtr);
  1.4865 +			PRINT((_L("CVDecTestEngine::LoadNextFrameL, frame1"), iFrame))
  1.4866 +			TUint8* ptr = new ( ELeave ) TUint8[8];    // dynamic alloc 3
  1.4867 +			iMemAlloc++;
  1.4868 +			#ifdef __MEM_CHECK_
  1.4869 +			PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem alloc, ptr") ))
  1.4870 +			#endif
  1.4871 +
  1.4872 +			Mem::FillZ( ptr, 8 );
  1.4873 +			ptr[0] = 1;
  1.4874 +			ptr[4] = 44;
  1.4875 +			TPtr8 anotherPtr(ptr, 8, 8);
  1.4876 +			aCodedInBuffer->iData.Insert(0, anotherPtr );
  1.4877 +			delete ptr2;
  1.4878 +			ptr2 = NULL;
  1.4879 +			delete ptr;
  1.4880 +			ptr = NULL;
  1.4881 +			iMemDelete += 2;
  1.4882 +			#ifdef __MEM_CHECK_
  1.4883 +			PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem del, ptr2 & ptr") ))
  1.4884 +			#endif
  1.4885 +		}
  1.4886 +		else
  1.4887 +		{
  1.4888 +			PRINT((_L("CVDecTestEngine::LoadNextFrameL, iFrame num != 0: %d"), iFrame ))
  1.4889 +			TInt pos = -8;
  1.4890 +
  1.4891 +			err = iInFile.Seek(ESeekCurrent, pos);
  1.4892 +			PRINT((_L("CVDecTestEngine::LoadNextFrameL, read file: %d"), err ))
  1.4893 +			if ( (err = iInFile.Read(aCodedInBuffer->iData, frameSize+8)) != KErrNone)
  1.4894 +			{
  1.4895 +				PRINT((_L("CVDecTestEngine::LoadNextFrameL, Error reading file %d"), err ))
  1.4896 +				return err;
  1.4897 +			}
  1.4898 +
  1.4899 +			TUint8* ptr2 = new(ELeave)TUint8[4];         // dynamic alloc 4
  1.4900 +			iMemAlloc++;
  1.4901 +			#ifdef __MEM_CHECK_
  1.4902 +			PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem alloc, ptr2") ))
  1.4903 +			#endif
  1.4904 +			Mem::FillZ(ptr2,4);
  1.4905 +			TPtr8 firstPtr(ptr2,4,4);
  1.4906 +			//			aCodedInBuffer->iData.Insert(0, firstPtr);
  1.4907 +			delete ptr2;
  1.4908 +			iMemDelete++;
  1.4909 +			#ifdef __MEM_CHECK_
  1.4910 +			PRINT((_L("CVDecTestEngine::LoadNextFrameL, mem del, ptr2") ))
  1.4911 +			#endif
  1.4912 +		}
  1.4913 +
  1.4914 +		TInt substreamID = 0;
  1.4915 +		if(aCodedInBuffer->iUser != NULL){
  1.4916 +			*((TInt*)aCodedInBuffer->iUser) = substreamID;
  1.4917 +		}
  1.4918 +		iInFile.Seek(ESeekCurrent, currentPos );
  1.4919 +		PRINT((_L("CVDecTestEngine::LoadNextFrameL, currentPos %d"), currentPos ))
  1.4920 +		currentPos = 0;
  1.4921 +
  1.4922 +		aCodedInBuffer->iSequenceNumber = iFrame;
  1.4923 +		aCodedInBuffer->iOptions = TVideoInputBuffer::EPresentationTimestamp;
  1.4924 +
  1.4925 +		aCodedInBuffer->iPresentationTimestamp = Timestamp;
  1.4926 +		iTimeToPlay = aCodedInBuffer->iPresentationTimestamp ;
  1.4927 +
  1.4928 +
  1.4929 +		aCodedInBuffer->iDecodingTimestamp = Timestamp;
  1.4930 +		iPresentationTimestamp = aCodedInBuffer->iPresentationTimestamp ;
  1.4931 +
  1.4932 +
  1.4933 +
  1.4934 +	}
  1.4935 +	iFrame++;
  1.4936 +	PRINT(_L("CVDecTestEngine::LoadNextFrameL.. Out"));
  1.4937 +	return frameSize;
  1.4938 +}
  1.4939 +
  1.4940 +
  1.4941 +/* ----------------------------------------------------------------------------
  1.4942 +* Name:       CVDecTestEngine::ReadItemLE()
  1.4943 +* Purpose:
  1.4944 +* Note:
  1.4945 +* Parameters: None
  1.4946 +* Return:     None
  1.4947 +* --------------------------------------------------------------------------*/
  1.4948 +//Currently Supporting only upto 4Bytes
  1.4949 +TBool CVDecTestEngine::ReadItemLE(unsigned char *readBuffer, int Size,
  1.4950 +unsigned char* pItem)
  1.4951 +{
  1.4952 +	PRINT((_L("CVDecTestEngine::ReadItemLE, In")));
  1.4953 +	unsigned int High=0, Low=0;
  1.4954 +	unsigned char m_char;
  1.4955 +	int shift = 0;
  1.4956 +	int numbytes = Size;
  1.4957 +	int i=0;
  1.4958 +
  1.4959 +	/* Read a little-endian file value into a variable, regardless of host endianness */
  1.4960 +	while (numbytes-- >0)
  1.4961 +	{
  1.4962 +		m_char  = readBuffer[i++];
  1.4963 +
  1.4964 +		if (shift >= 32)
  1.4965 +		{
  1.4966 +			High |= m_char << (shift-32);
  1.4967 +		}
  1.4968 +		else
  1.4969 +		{
  1.4970 +			Low  |= m_char << shift;
  1.4971 +		}
  1.4972 +		shift += 8;
  1.4973 +	}
  1.4974 +
  1.4975 +	switch (Size)
  1.4976 +	{
  1.4977 +		case 1:
  1.4978 +		*pItem = (unsigned char)Low;
  1.4979 +		break;
  1.4980 +
  1.4981 +		case 2:
  1.4982 +		*(unsigned short *)pItem = (unsigned short)Low;
  1.4983 +		break;
  1.4984 +
  1.4985 +		case 4:
  1.4986 +		*(unsigned int *)pItem = (unsigned int)Low;
  1.4987 +		break;
  1.4988 +
  1.4989 +		default:
  1.4990 +		//WARN("Unknown size (%d) item read requested",Size);
  1.4991 +		//return false;
  1.4992 +		return EFalse;
  1.4993 +	}
  1.4994 +
  1.4995 +	PRINT((_L("CVDecTestEngine::ReadItemLE, Out")));
  1.4996 +	return TRUE;
  1.4997 +}
  1.4998 +
  1.4999 +/* ----------------------------------------------------------------------------
  1.5000 +* Name:       CVDecTestEngine::GoBackInFile()
  1.5001 +* Purpose:
  1.5002 +* Note:
  1.5003 +* Parameters: None
  1.5004 +* Return:     None
  1.5005 +* --------------------------------------------------------------------------*/
  1.5006 +void CVDecTestEngine::GoBackInFile(TUint aBytes)
  1.5007 +{
  1.5008 +	PRINT((_L("CVDecTestEngine::GoBackInFile, In")));
  1.5009 +
  1.5010 +	//If read pointer is in the end of the buffer change it in the beginning
  1.5011 +	if (iReadDataChunk - iDataChunk >= aBytes)
  1.5012 +	{
  1.5013 +		iReadDataChunk -= aBytes;
  1.5014 +	}
  1.5015 +	else
  1.5016 +	{
  1.5017 +		TInt endBytes = aBytes - (iReadDataChunk - iDataChunk);
  1.5018 +		iReadDataChunk = iDataChunk+iDataChunkSize-endBytes;
  1.5019 +	}
  1.5020 +
  1.5021 +	PRINT((_L("CVDecTestEngine::GoBackInFile, Out, ")));
  1.5022 +}
  1.5023 +
  1.5024 +
  1.5025 +
  1.5026 +/* ----------------------------------------------------------------------------
  1.5027 +* Name:       CVDecTestEngine::ReadByteFromFile()
  1.5028 +* Purpose:
  1.5029 +* Note:
  1.5030 +* Parameters: None
  1.5031 +* Return:     None
  1.5032 +* --------------------------------------------------------------------------*/
  1.5033 +TUint8 CVDecTestEngine::ReadByteFromFile()
  1.5034 +{
  1.5035 +	//PRINT((_L("CVDecTestEngine::ReadByteFromFile, In")));
  1.5036 +	if (iDataReadFromFile == 0)
  1.5037 +	{
  1.5038 +		TInt err = CheckAndFillDataChunk();
  1.5039 +		if (err )
  1.5040 +		{
  1.5041 +			PRINT((_L("CVDecTestEngine::ReadByteFromFile, ERROR [%d]"), err));
  1.5042 +			return 0;
  1.5043 +		}
  1.5044 +	}
  1.5045 +
  1.5046 +	if (iReadDataChunk >= iDataChunk+iDataChunkSize)
  1.5047 +	{
  1.5048 +		iReadDataChunk = iDataChunk;
  1.5049 +	}
  1.5050 +
  1.5051 +	if (iEndOfData && iReadDataChunk == iWriteDataChunk && iDataReadFromFile != 0)
  1.5052 +	{
  1.5053 +		PRINT((_L("CVDecTestEngine::ReadByteFromFile, Input End found")));
  1.5054 +		iInputEnd = ETrue;
  1.5055 +		TUint8 value = 0;
  1.5056 +		return value;
  1.5057 +	}
  1.5058 +
  1.5059 +
  1.5060 +	TUint8 byte = iReadDataChunk[0];
  1.5061 +	iReadDataChunk++;
  1.5062 +	return byte;
  1.5063 +
  1.5064 +}
  1.5065 +
  1.5066 +
  1.5067 +/* ----------------------------------------------------------------------------
  1.5068 +* Name:       CVDecTestEngine::ReadDataToBuffer()
  1.5069 +* Purpose:
  1.5070 +* Note:
  1.5071 +* Parameters: None
  1.5072 +* Return:     None
  1.5073 +* --------------------------------------------------------------------------*/
  1.5074 +void CVDecTestEngine::ReadDataToBuffer(TVideoInputBuffer* aCodedInBuffer, TInt aSize, TBool aDiscard)
  1.5075 +{
  1.5076 +	PRINT((_L("CVDecTestEngine::ReadDataToBuffer, In")));
  1.5077 +	PRINT((_L("CVDecTestEngine::ReadDataToBuffer, iWriteDataChunk [%x]"), iWriteDataChunk));
  1.5078 +	PRINT((_L("CVDecTestEngine::ReadDataToBuffer, iReadDataChunk [%x]"), iReadDataChunk));
  1.5079 +	PRINT((_L("CVDecTestEngine::ReadDataToBuffer, iDataChunk [%x]"), iDataChunk));
  1.5080 +	PRINT((_L("CVDecTestEngine::ReadDataToBuffer, size [%d]"), aSize));
  1.5081 +
  1.5082 +
  1.5083 +
  1.5084 +	TInt err = CheckAndFillDataChunk();
  1.5085 +	if (err )
  1.5086 +	{
  1.5087 +		PRINT((_L("CVDecTestEngine::ReadDataToBuffer, ERROR [%d]"), err));
  1.5088 +		return;
  1.5089 +	}
  1.5090 +
  1.5091 +	aCodedInBuffer->iData.Zero();
  1.5092 +
  1.5093 +	if (iEndOfData)
  1.5094 +	{
  1.5095 +		if (iReadDataChunk == iWriteDataChunk && iDataReadFromFile != 0)
  1.5096 +		{
  1.5097 +			PRINT((_L("CVDecTestEngine::ReadByteFromFile, Input End found")));
  1.5098 +			iInputEnd = ETrue;
  1.5099 +			return;
  1.5100 +		}
  1.5101 +
  1.5102 +		if (iReadDataChunk+aSize > iWriteDataChunk && iReadDataChunk < iWriteDataChunk)
  1.5103 +		{
  1.5104 +			PRINT((_L("CVDecTestEngine::ReadByteFromFile, Input End found")));
  1.5105 +			if (!aDiscard)
  1.5106 +			{
  1.5107 +				aCodedInBuffer->iData.Append(iReadDataChunk, (iWriteDataChunk-iReadDataChunk));
  1.5108 +			}
  1.5109 +			iReadDataChunk += aSize;
  1.5110 +			iInputEnd = ETrue;
  1.5111 +			return;
  1.5112 +		}
  1.5113 +		else if (iReadDataChunk+aSize > iDataChunk+iDataChunkSize && iReadDataChunk > iWriteDataChunk &&
  1.5114 +		iDataChunk+aSize-(iDataChunkSize+iDataChunk-iReadDataChunk) > iWriteDataChunk)
  1.5115 +		{
  1.5116 +			PRINT((_L("CVDecTestEngine::ReadByteFromFile, Input End found")));
  1.5117 +			if (!aDiscard)
  1.5118 +			{
  1.5119 +				aCodedInBuffer->iData.Append(iReadDataChunk, (iDataChunkSize+(iDataChunk-iReadDataChunk)));
  1.5120 +			}
  1.5121 +			iReadDataChunk = iDataChunk;
  1.5122 +			if (!aDiscard)
  1.5123 +			{
  1.5124 +				aCodedInBuffer->iData.Append(iReadDataChunk, (iWriteDataChunk-iReadDataChunk));
  1.5125 +			}
  1.5126 +			iReadDataChunk += iWriteDataChunk-iReadDataChunk;
  1.5127 +			iInputEnd = ETrue;
  1.5128 +			return;
  1.5129 +		}
  1.5130 +	}
  1.5131 +
  1.5132 +	if (iReadDataChunk+aSize <= iDataChunk+iDataChunkSize)
  1.5133 +	{
  1.5134 +		if (!aDiscard)
  1.5135 +		{
  1.5136 +			aCodedInBuffer->iData.Append(iReadDataChunk, aSize);
  1.5137 +		}
  1.5138 +		iReadDataChunk +=aSize;
  1.5139 +	}
  1.5140 +	else if (iReadDataChunk+aSize > iDataChunk+iDataChunkSize)
  1.5141 +	{
  1.5142 +		PRINT((_L("CVDecTestEngine::ReadDataToBuffer, iReadDataChunk+aSize > iDataChunk+iDataChunkSize")));
  1.5143 +		if (!aDiscard)
  1.5144 +		{
  1.5145 +			aCodedInBuffer->iData.Append(iReadDataChunk, (iDataChunkSize+iDataChunk-iReadDataChunk));
  1.5146 +		}
  1.5147 +		TInt end = aSize - ( iDataChunkSize+iDataChunk - iReadDataChunk );
  1.5148 +		iReadDataChunk = iDataChunk;
  1.5149 +		PRINT( ( _L( "CVDecTestEngine::ReadDataToBuffer, iReadDataChunk = iDataChunk") ) );
  1.5150 +		if (!aDiscard)
  1.5151 +		{
  1.5152 +			aCodedInBuffer->iData.Append(iReadDataChunk, end);
  1.5153 +		}
  1.5154 +		iReadDataChunk += end;
  1.5155 +	}
  1.5156 +
  1.5157 +	err = CheckAndFillDataChunk();
  1.5158 +	if (err )
  1.5159 +	{
  1.5160 +		PRINT((_L("CVDecTestEngine::ReadDataToBuffer, ERROR [%d]"), err));
  1.5161 +
  1.5162 +		return;
  1.5163 +	};
  1.5164 +	PRINT((_L("CVDecTestEngine::ReadDataToBuffer, Out")));
  1.5165 +}
  1.5166 +
  1.5167 +/* ----------------------------------------------------------------------------
  1.5168 +* Name:       CVDecTestEngine::CheckAndFillDataChunk()
  1.5169 +* Purpose:
  1.5170 +* Note:
  1.5171 +* Parameters: None
  1.5172 +* Return:     None
  1.5173 +* --------------------------------------------------------------------------*/
  1.5174 +TInt CVDecTestEngine::CheckAndFillDataChunk()
  1.5175 +{
  1.5176 +	PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, In")));
  1.5177 +
  1.5178 +	TInt err = KErrNone;
  1.5179 +
  1.5180 +	//If all the data is read return KerrNone
  1.5181 +	if (iEndOfData)
  1.5182 +	{
  1.5183 +		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, End of data")));
  1.5184 +		return KErrNone;
  1.5185 +	}
  1.5186 +
  1.5187 +	TInt32 read = (TInt32)(iReadDataChunk);
  1.5188 +	TInt32 write = (TInt32)(iWriteDataChunk);
  1.5189 +	TInt32 chunk = (TInt32)(iDataChunkSize);
  1.5190 +	TInt32 thres = (TInt32)(iDataThreshold);
  1.5191 +	//First time fill the whole buffer
  1.5192 +
  1.5193 +	PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, read %d, write %d, chunk %d, thres %d"), read, write, chunk, thres));
  1.5194 +
  1.5195 +	if (iDataReadFromFile == 0)
  1.5196 +	{
  1.5197 +		TPtr8 temp(iWriteDataChunk, iDataChunkSize, iDataChunkSize);
  1.5198 +		if ( (err = iInFile.Read(temp, iDataChunkSize)) != KErrNone)
  1.5199 +		{
  1.5200 +			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, Infile read [%d]"), err));
  1.5201 +			return err;
  1.5202 +		}
  1.5203 +		if (temp.Length() < iDataChunkSize)
  1.5204 +		{
  1.5205 +			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, end of file found [%d]"), temp.Length()));
  1.5206 +			if(temp.Length()== 0){
  1.5207 +				PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, Error! Trying to read zero-sized input file")));
  1.5208 +				iInputEnd = ETrue;
  1.5209 +			}
  1.5210 +			iEndOfData = ETrue;
  1.5211 +			iWriteDataChunk += temp.Length();
  1.5212 +			iDataReadFromFile += temp.Length();
  1.5213 +			return KErrNone;
  1.5214 +		}
  1.5215 +		iDataReadFromFile += iDataChunkSize;
  1.5216 +		for (TUint i = 0; i < 20; i++)
  1.5217 +		{
  1.5218 +			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, [%x]"), iReadDataChunk[i]));
  1.5219 +		}
  1.5220 +	}
  1.5221 +	else if (((read-write) > (chunk-thres)) && (iSentBuffCount != 0))
  1.5222 +	{
  1.5223 +		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, iReadDataChunk-iWriteDataChunk > iDataChunkSize-iDataThreshold")));
  1.5224 +		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, iWriteDataChunk [%x]"), iWriteDataChunk));
  1.5225 +		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, iReadDataChunk [%x]"), iReadDataChunk));
  1.5226 +		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, iDataChunk [%x]"), iDataChunk));
  1.5227 +		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, iReadDataChunk-iWriteDataChunk [%d]"), iReadDataChunk-iWriteDataChunk));
  1.5228 +		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, iDataChunkSize-iDataThreshold [%d]"), iDataChunkSize-iDataThreshold));
  1.5229 +
  1.5230 +		TPtr8 temp(iWriteDataChunk, iReadDataChunk-iWriteDataChunk, iReadDataChunk-iWriteDataChunk);
  1.5231 +		if ( (err = iInFile.Read(temp, (iReadDataChunk-iWriteDataChunk))) != KErrNone)
  1.5232 +		{
  1.5233 +			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, Infile read [%d]"), err));
  1.5234 +			return err;
  1.5235 +		}
  1.5236 +		if (temp.Length() < iReadDataChunk-iWriteDataChunk)
  1.5237 +		{
  1.5238 +			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, End of file found [%d]"), temp.Length()));
  1.5239 +			iEndOfData = ETrue;
  1.5240 +			iWriteDataChunk += temp.Length();
  1.5241 +			return KErrNone;
  1.5242 +		}
  1.5243 +		iWriteDataChunk += iReadDataChunk-iWriteDataChunk;
  1.5244 +		iDataReadFromFile += iReadDataChunk-iWriteDataChunk;
  1.5245 +	}
  1.5246 +	else if (((write-read) < thres) && (iSentBuffCount != 0) && ((write-read) > 0))
  1.5247 +	{
  1.5248 +		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, iReadDataChunk-iWriteDataChunk > -iDataThreshold")));
  1.5249 +		//fill end of the buffer
  1.5250 +		TPtr8 end(iWriteDataChunk, iDataChunk+iDataChunkSize-iWriteDataChunk, iDataChunk+iDataChunkSize-iWriteDataChunk);
  1.5251 +		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, TPtr created")));
  1.5252 +		if ( (err = iInFile.Read(end, (iDataChunkSize+iDataChunk-iWriteDataChunk))) != KErrNone)
  1.5253 +		{
  1.5254 +			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, Infile read [%d]"), err));
  1.5255 +			return err;
  1.5256 +		}
  1.5257 +		if (end.Length() < (iDataChunkSize+iDataChunk-iWriteDataChunk))
  1.5258 +		{
  1.5259 +			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, End of file found [%d]"), end.Length()));
  1.5260 +			iEndOfData = ETrue;
  1.5261 +			iWriteDataChunk += end.Length();
  1.5262 +			return KErrNone;
  1.5263 +		}
  1.5264 +
  1.5265 +		//fill beginning of the buffer
  1.5266 +		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, end of data chunk filled [%d]"), end.Length()));
  1.5267 +		TPtr8 begin(iDataChunk, iReadDataChunk-iDataChunk, iReadDataChunk-iDataChunk);
  1.5268 +		if ( (err = iInFile.Read(begin, iReadDataChunk-iDataChunk)) != KErrNone)
  1.5269 +		{
  1.5270 +			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, Infile read [%d]"), err));
  1.5271 +			return err;
  1.5272 +		}
  1.5273 +		if (begin.Length() < (iReadDataChunk-iDataChunk))
  1.5274 +		{
  1.5275 +			PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, End of file found [%d]"), begin.Length()));
  1.5276 +			iEndOfData = ETrue;
  1.5277 +			iWriteDataChunk = iDataChunk+begin.Length();
  1.5278 +			return KErrNone;
  1.5279 +		}
  1.5280 +		iWriteDataChunk = iDataChunk+begin.Length();
  1.5281 +		PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, beginning of data chunk filled [%d]"), begin.Length()));
  1.5282 +		iDataReadFromFile += iDataChunkSize-(iWriteDataChunk-iReadDataChunk);
  1.5283 +	}
  1.5284 +	else if (iWriteDataChunk == iDataChunk+iDataChunkSize)
  1.5285 +	{
  1.5286 +		iWriteDataChunk = iDataChunk;
  1.5287 +	}
  1.5288 +
  1.5289 +	PRINT((_L("CVDecTestEngine::CheckAndFillDataChunk, Out")));
  1.5290 +	return err;
  1.5291 +}
  1.5292 +
  1.5293 +/* ----------------------------------------------------------------------------
  1.5294 +* Name:       CVDecTestEngine::PrintUncompressedFormat()
  1.5295 +* Purpose:    Get Next input data
  1.5296 +* Note:
  1.5297 +* Parameters: None
  1.5298 +* Return:     None
  1.5299 +* --------------------------------------------------------------------------*/
  1.5300 +
  1.5301 +
  1.5302 +void CVDecTestEngine::PrintUncompressedFormat(const TUncompressedVideoFormat& aFormat)
  1.5303 +{
  1.5304 +	PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, In")))
  1.5305 +
  1.5306 +	switch (aFormat.iDataFormat)
  1.5307 +	{
  1.5308 +		case ERgbRawData:
  1.5309 +		PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iDataFormat = ERgbRawData")))
  1.5310 +		case ERgbFbsBitmap:
  1.5311 +		PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iDataFormat = ERgbFbsBitmap")))
  1.5312 +		switch(aFormat.iRgbFormat)
  1.5313 +		{
  1.5314 +			case ERgb16bit444:
  1.5315 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iRgbFormat = ERgb16bit444")))
  1.5316 +			break;
  1.5317 +			case ERgb16bit565:
  1.5318 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iRgbFormat = ERgb16bit565")))
  1.5319 +			break;
  1.5320 +			case ERgb32bit888:
  1.5321 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iRgbFormat = ERgb32bit888")))
  1.5322 +			break;
  1.5323 +			case EFbsBitmapColor4K:
  1.5324 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iRgbFormat = EFbsBitmapColor4K")))
  1.5325 +			break;
  1.5326 +			case EFbsBitmapColor64K:
  1.5327 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iRgbFormat = EFbsBitmapColor64K")))
  1.5328 +			break;
  1.5329 +			case EFbsBitmapColor16M:
  1.5330 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iRgbFormat = EFbsBitmapColor16M")))
  1.5331 +			break;
  1.5332 +			case EFbsBitmapColor16MU:
  1.5333 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iRgbFormat = EFbsBitmapColor16MU")))
  1.5334 +			break;
  1.5335 +			default:
  1.5336 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, Error reading iRgbFormat [%x]"), aFormat.iRgbFormat))
  1.5337 +		}
  1.5338 +		break;
  1.5339 +		case EYuvRawData:
  1.5340 +		PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iDataFormat = EYuvRawData")))
  1.5341 +		switch(aFormat.iYuvFormat.iCoefficients)
  1.5342 +		{
  1.5343 +			case EYuvRange0:
  1.5344 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = EYuvRange0")))
  1.5345 +			break;
  1.5346 +			case EYuvRange1:
  1.5347 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = EYuvRange1")))
  1.5348 +			break;
  1.5349 +			case EYuvBt709:
  1.5350 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = EYuvBt709")))
  1.5351 +			break;
  1.5352 +			case EYuvBt709Range0:
  1.5353 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = EYuvBt709Range0")))
  1.5354 +			break;
  1.5355 +			case EYuvBt709Range1:
  1.5356 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = EYuvBt709Range1")))
  1.5357 +			break;
  1.5358 +			case EYuvBt601:
  1.5359 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = EYuvBt601")))
  1.5360 +			break;
  1.5361 +			case EYuvBt601Range0:
  1.5362 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = EYuvBt601Range0")))
  1.5363 +			break;
  1.5364 +			case EYuvBt601Range1:
  1.5365 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = EYuvBt601Range1")))
  1.5366 +			break;
  1.5367 +			case ECustomYuvMatrix:
  1.5368 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iCoefficients = ECustomYuvMatrix")))
  1.5369 +			break;
  1.5370 +			default:
  1.5371 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, Error reading iCoefficients [%x]"), aFormat.iYuvFormat.iCoefficients))
  1.5372 +		}
  1.5373 +		switch(aFormat.iYuvFormat.iPattern)
  1.5374 +		{
  1.5375 +			case EYuv420Chroma1:
  1.5376 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iPattern = EYuv420Chroma1")))
  1.5377 +			break;
  1.5378 +			case EYuv420Chroma2:
  1.5379 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iPattern = EYuv420Chroma2")))
  1.5380 +			break;
  1.5381 +			case EYuv420Chroma3:
  1.5382 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iPattern = EYuv420Chroma3")))
  1.5383 +			break;
  1.5384 +			case EYuv422Chroma1:
  1.5385 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iPattern = EYuv422Chroma1")))
  1.5386 +			break;
  1.5387 +			case EYuv422Chroma2:
  1.5388 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iPattern = EYuv422Chroma2")))
  1.5389 +			break;
  1.5390 +			default:
  1.5391 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, Error reading iPattern [%x]"), aFormat.iYuvFormat.iPattern))
  1.5392 +		}
  1.5393 +		switch(aFormat.iYuvFormat.iDataLayout)
  1.5394 +		{
  1.5395 +			case EYuvDataPlanar:
  1.5396 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iDataLayout = EYuvDataPlanar")))
  1.5397 +			break;
  1.5398 +			case EYuvDataInterleavedLE:
  1.5399 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iDataLayout = EYuvDataInterleavedLE")))
  1.5400 +			break;
  1.5401 +			case EYuvDataInterleavedBE:
  1.5402 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iDataLayout = EYuvDataInterleavedBE")))
  1.5403 +			break;
  1.5404 +			case EYuvDataSemiPlanar:
  1.5405 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iDataLayout = EYuvDataSemiPlanar")))
  1.5406 +			break;
  1.5407 +			default:
  1.5408 +			PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, Error reading iDataLayout [%x]"), aFormat.iYuvFormat.iDataLayout))
  1.5409 +		}
  1.5410 +		PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iAspectRatioNum [%d]"), aFormat.iYuvFormat.iAspectRatioNum))
  1.5411 +		PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, iAspectRatioDenom [%d]"), aFormat.iYuvFormat.iAspectRatioDenom))
  1.5412 +		break;
  1.5413 +		default :
  1.5414 +		PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, Error reading iDataFormat [%x]"), aFormat.iDataFormat))
  1.5415 +	}
  1.5416 +
  1.5417 +	PRINT((_L("CVDecTestEngine::PrintUncompressedFormat, Out")))
  1.5418 +}
  1.5419 +
  1.5420 +/* ----------------------------------------------------------------------------
  1.5421 +* Name:       CVDecTestEngine::ConvertToRealL()
  1.5422 +* Purpose:    Converts the given descriptor to TReal
  1.5423 +* Parameters: const TDesC& aPtr
  1.5424 +* Return:     TReal
  1.5425 +* --------------------------------------------------------------------------*/
  1.5426 +
  1.5427 +TReal CVDecTestEngine::ConvertToRealL(const TDesC& aPtr)
  1.5428 +{
  1.5429 +	PRINT((_L("CVDecTestEngine::ConvertToReal(),In")))
  1.5430 +
  1.5431 +	TInt point = aPtr.Find(_L("."));
  1.5432 +
  1.5433 +	TBufC<7> integer;
  1.5434 +	TBufC<7> decimal;
  1.5435 +	if (point != KErrNotFound)
  1.5436 +	{
  1.5437 +
  1.5438 +		integer = aPtr.Mid(0, point);
  1.5439 +		decimal = aPtr.Mid(point+1);
  1.5440 +	}
  1.5441 +	else
  1.5442 +	{
  1.5443 +		User::Leave(KErrArgument);
  1.5444 +	}
  1.5445 +	TInt decimalInt = 0;
  1.5446 +	TInt integerInt = 0;
  1.5447 +	TLex lexInt(integer);
  1.5448 +	TLex lexDec(decimal);
  1.5449 +
  1.5450 +	if (lexInt.Val(integerInt) != KErrNone || lexDec.Val(decimalInt) != KErrNone)
  1.5451 +	{
  1.5452 +		PRINT((_L("CVDecTestEngine::ConvertToReal(), error in descriptor")))
  1.5453 +		User::Leave(KErrArgument);
  1.5454 +	}
  1.5455 +
  1.5456 +
  1.5457 +	TReal real = 1.0;
  1.5458 +	TReal length = static_cast<TReal>(aPtr.Length()-point-1);
  1.5459 +	TReal denom = pow(10.0, length);
  1.5460 +
  1.5461 +
  1.5462 +	real = (static_cast<TReal>(integerInt)) + (static_cast<TReal>(decimalInt)/denom);
  1.5463 +
  1.5464 +	PRINT((_L("CVDecTestEngine::ConvertToReal(),integer [%d]"), integerInt))
  1.5465 +	PRINT((_L("CVDecTestEngine::ConvertToReal(),decimal [%d]"), decimalInt))
  1.5466 +	PRINT((_L("CVDecTestEngine::ConvertToReal(),denom [%f]"), denom))
  1.5467 +	PRINT((_L("CVDecTestEngine::ConvertToReal(),real [%f]"), real))
  1.5468 +
  1.5469 +	PRINT((_L("CVDecTestEngine::ConvertToReal(),Out")))
  1.5470 +	return real;
  1.5471 +}
  1.5472 +
  1.5473 +
  1.5474 +/* ----------------------------------------------------------------------------
  1.5475 +* Name:       CVDecTestEngine::MdvpoNewBuffers()
  1.5476 +* Purpose:    Availability of Next buffer is notified
  1.5477 +* Note:
  1.5478 +* Parameters: None
  1.5479 +* Return:     None
  1.5480 +* --------------------------------------------------------------------------*/
  1.5481 +
  1.5482 +
  1.5483 +void CVDecTestEngine::MdvpoNewBuffers()
  1.5484 +{
  1.5485 +	PRINT((_L("CVDecTestEngine::MdvpoNewBuffers(), Newbuffer is available")))
  1.5486 +
  1.5487 +	//if ( iFrameMeasurement )
  1.5488 +	//    return;
  1.5489 +
  1.5490 +	if ( iState == ERunning)
  1.5491 +	{
  1.5492 +		iDecTestAO->RequestData();
  1.5493 +	}
  1.5494 +
  1.5495 +
  1.5496 +}
  1.5497 +
  1.5498 +/* ----------------------------------------------------------------------------
  1.5499 +* Name:       CVDecTestEngine::MdvpoReturnPicture()
  1.5500 +* Purpose:    Postprocessor Input buffer is returned
  1.5501 +* Note:       Used when input to Postprocessing
  1.5502 +* Parameters: TVideoPicture* aPicture
  1.5503 +* Return:     None
  1.5504 +* --------------------------------------------------------------------------*/
  1.5505 +
  1.5506 +
  1.5507 +void CVDecTestEngine::MdvpoReturnPicture(TVideoPicture* aPicture)
  1.5508 +{
  1.5509 +	if ( iRawInBuffer == aPicture )
  1.5510 +	{
  1.5511 +		PRINT((_L("CVDecTestEngine::MdvpoReturnPicture, a Picture returned ")))
  1.5512 +		iDecTestAO->RequestData();
  1.5513 +
  1.5514 +	}
  1.5515 +	else
  1.5516 +	{
  1.5517 +		PRINT((_L("CVDecTestEngine::MdvpoReturnPicture, Returned picture unknown")))
  1.5518 +		iError = KErrGeneral;
  1.5519 +	}
  1.5520 +}
  1.5521 +
  1.5522 +
  1.5523 +
  1.5524 +/* ----------------------------------------------------------------------------
  1.5525 +* Name:       CVDecTestEngine::MdvpoSupplementalInformation()
  1.5526 +* Purpose:    Supplementary information is notified
  1.5527 +* Note:
  1.5528 +* Parameters: const TDesC8& aData, const TTimeIntervalMicroSeconds& aTimestamp, const TPictureId& aPictureId
  1.5529 +* Return:     None
  1.5530 +* --------------------------------------------------------------------------*/
  1.5531 +
  1.5532 +
  1.5533 +void CVDecTestEngine::MdvpoSupplementalInformation(const TDesC8& /*aData*/, const TTimeIntervalMicroSeconds& /*aTimestamp*/, const TPictureId& /*aPictureId*/)
  1.5534 +{
  1.5535 +	PRINT((_L("CVDecTestEngine::MdvpoSupplementalInformation  ")))
  1.5536 +}
  1.5537 +
  1.5538 +
  1.5539 +/* ----------------------------------------------------------------------------
  1.5540 +* Name:       CVDecTestEngine::MdvpoPictureLoss()
  1.5541 +* Purpose:    Loss of a picture is notified
  1.5542 +* Note:
  1.5543 +* Parameters: None
  1.5544 +* Return:     None
  1.5545 +* --------------------------------------------------------------------------*/
  1.5546 +
  1.5547 +void CVDecTestEngine::MdvpoPictureLoss()
  1.5548 +{
  1.5549 +	iPictureLoss++;
  1.5550 +	PRINT((_L("CVDecTestEngine::MdvpoPictureLoss, A picture lost. ")))
  1.5551 +
  1.5552 +}
  1.5553 +
  1.5554 +
  1.5555 +/* ----------------------------------------------------------------------------
  1.5556 +* Name:       CVDecTestEngine::MdvpoPictureLoss()
  1.5557 +* Purpose:    Loss of pictures is notified
  1.5558 +* Note:
  1.5559 +* Parameters: const TArray<TPictureId>& aPictures
  1.5560 +* Return:     None
  1.5561 +* --------------------------------------------------------------------------*/
  1.5562 +
  1.5563 +void CVDecTestEngine::MdvpoPictureLoss(const TArray<TPictureId>& aPictures)
  1.5564 +{
  1.5565 +	TInt count = aPictures.Count();
  1.5566 +	iPictureLoss += count;
  1.5567 +	PRINT((_L("CVDecTestEngine::MdvpoPictureLoss, [%d] pictures lost. "),count))
  1.5568 +
  1.5569 +	for ( TInt i =0; i<count;i++ )
  1.5570 +	{
  1.5571 +		TPictureId id = aPictures[i];
  1.5572 +		PRINT((_L("CVDecTestEngine::MdvpoPictureLoss, Picure:[%d]"),i))
  1.5573 +
  1.5574 +		/*       if(id.iIdType == TPictureId::EPictureNumber)
  1.5575 +		PRINT((_L("CVDecTestEngine::MdvpoPictureLoss, Picture Type:Picture Number, ID:[%d]"),id.iId))
  1.5576 +		else if (id.iIdType == TPictureId::ETemporalReference)
  1.5577 +		PRINT((_L("CVDecTestEngine::MdvpoPictureLoss, Picture Type:Temporal Reference, ID:[%d]"),id.iId))
  1.5578 +		else
  1.5579 +		PRINT((_L("CVDecTestEngine::MdvpoPictureLoss, Picture Type:Unidentified piture")))
  1.5580 +		*/
  1.5581 +	}
  1.5582 +}
  1.5583 +
  1.5584 +/* ----------------------------------------------------------------------------
  1.5585 +* Name:       CVDecTestEngine::MdvpoSliceLoss
  1.5586 +* Purpose:    Loss of slice is notified
  1.5587 +* Note:
  1.5588 +* Parameters: TUint aFirstMacroblock, TUint aNumMacroblocks, const TPictureId& aPicture
  1.5589 +* Return:     None
  1.5590 +* --------------------------------------------------------------------------*/
  1.5591 +
  1.5592 +void CVDecTestEngine::MdvpoSliceLoss(TUint /*aFirstMacroblock*/, TUint /*aNumMacroblocks*/, const TPictureId& /*aPicture*/)
  1.5593 +{
  1.5594 +
  1.5595 +	PRINT((_L("CVDecTestEngine::MdvpoSliceLoss, In")))
  1.5596 +
  1.5597 +	//    PRINT((_L("CVDecTestEngine::MdvpoSliceLoss, [%d] consecutive Mactoblocks from [%d] in raster-scan order are lost"),aPicture.aNumMacroblocks ,aPicture.aFirstMacroblock))
  1.5598 +	/*    if( aPicture.iIdType == TPictureId::EPictureNumber)
  1.5599 +	PRINT((_L("CVDecTestEngine::MdvpoSliceLoss, Picture Type:Picture Number, ID:[%d]"),aPicture.iId))
  1.5600 +	else if (aPicture.iIdType == TPictureId::ETemporalReference)
  1.5601 +	PRINT((_L("CVDecTestEngine::MdvpoSliceLoss, Picture Type:Temporal Reference, ID:[%d]"),aPicture.iId))
  1.5602 +	else
  1.5603 +	PRINT((_L("CVDecTestEngine::MdvpoSliceLoss, Picture Type:Unidentified piture")))
  1.5604 +	*/
  1.5605 +
  1.5606 +}
  1.5607 +
  1.5608 +
  1.5609 +/* ----------------------------------------------------------------------------
  1.5610 +* Name:       CVDecTestEngine::MdvpoReferencePictureSelection
  1.5611 +* Purpose:
  1.5612 +* Note:
  1.5613 +* Parameters: const TDesC8& aSelectionData
  1.5614 +* Return:     None
  1.5615 +* --------------------------------------------------------------------------*/
  1.5616 +
  1.5617 +
  1.5618 +void CVDecTestEngine::MdvpoReferencePictureSelection(const TDesC8& /*aSelectionData*/)
  1.5619 +{
  1.5620 +	PRINT((_L("CVDecTestEngine::MdvpoReferencePictureSelection ")))
  1.5621 +
  1.5622 +}
  1.5623 +
  1.5624 +/* ----------------------------------------------------------------------------
  1.5625 +* Name:       CVDecTestEngine::MdvpoTimedSnapshotComplete()
  1.5626 +* Purpose:
  1.5627 +* Note:
  1.5628 +* Parameters: TInt aError, TPictureData* aPictureData, const TTimeIntervalMicroSeconds& aPresentationTimestamp, const TPictureId& aPictureId
  1.5629 +* Return:     None
  1.5630 +* --------------------------------------------------------------------------*/
  1.5631 +
  1.5632 +void CVDecTestEngine::MdvpoTimedSnapshotComplete(TInt aError, TPictureData* aPictureData, const TTimeIntervalMicroSeconds& /*aPresentationTimestamp*/, const TPictureId& aPictureId)
  1.5633 +{
  1.5634 +	PRINT((_L("CVDecTestEngine::MdvpoTimedSnapshotComplete(),In, error [%d]"), aError))
  1.5635 +
  1.5636 +	if ( aError == KErrNone )
  1.5637 +	{
  1.5638 +		RFile snapshot;
  1.5639 +
  1.5640 +		TFileName filename;
  1.5641 +		TBuf8<128> newFile;
  1.5642 +		newFile.Delete(newFile.Length()-5, 4);
  1.5643 +		newFile.Append(_L("_id_"));
  1.5644 +		newFile.AppendNum(aPictureId.iId);
  1.5645 +		newFile.Append(_L(".yuv"));
  1.5646 +		filename.Copy(newFile);
  1.5647 +
  1.5648 +		TInt err = snapshot.Replace(iFs, filename, EFileShareExclusive|EFileWrite);
  1.5649 +
  1.5650 +		if ( err != KErrNone )
  1.5651 +		{
  1.5652 +			PRINT((_L("CVDecTestEngine::GetSnapshotL, snapshot file open failed")))
  1.5653 +			snapshot.Close();
  1.5654 +			User::Leave(err);
  1.5655 +		}
  1.5656 +		else
  1.5657 +		{
  1.5658 +			err = snapshot.Write(*(aPictureData->iRawData),aPictureData->iRawData->Size());
  1.5659 +			if ( err!= KErrNone )
  1.5660 +			{
  1.5661 +				PRINT((_L("CVDecTestEngine::GetSnapshotL, snapshot file write failed")))
  1.5662 +				snapshot.Close();
  1.5663 +				User::Leave(err);
  1.5664 +			}
  1.5665 +		}
  1.5666 +		PRINT((_L("CVDecTestEngine::GetSnapshotL, Picture size"),aPictureData->iRawData->Size()));
  1.5667 +		snapshot.Close();
  1.5668 +	}
  1.5669 +	PRINT((_L("CVDecTestEngine::MdvpoTimedSnapshotComplete(),Out")))
  1.5670 +}
  1.5671 +
  1.5672 +
  1.5673 +/* ----------------------------------------------------------------------------
  1.5674 +* Name:       CVDecTestEngine::MdvpoNewPictures()
  1.5675 +* Purpose:
  1.5676 +* Note:
  1.5677 +* Parameters: None
  1.5678 +* Return:     None
  1.5679 +* --------------------------------------------------------------------------*/
  1.5680 +
  1.5681 +void CVDecTestEngine::MdvpoNewPictures()
  1.5682 +{
  1.5683 +
  1.5684 +	PRINT((_L("CVDecTestEngine::MdvpoNewPictures(),In, New output picture is available")))
  1.5685 +
  1.5686 +	GetReturnedPictureL();
  1.5687 +}
  1.5688 +
  1.5689 +
  1.5690 +
  1.5691 +/* ----------------------------------------------------------------------------
  1.5692 +* Name:       CVDecTestEngine::MdvpoFatalError()
  1.5693 +* Purpose:    Fatal error is notified
  1.5694 +* Note:       Decoder/Postprocessor to be deleted
  1.5695 +* Parameters: TInt aError
  1.5696 +* Return:     None
  1.5697 +* --------------------------------------------------------------------------*/
  1.5698 +
  1.5699 +void CVDecTestEngine::MdvpoFatalError(TInt aError)
  1.5700 +{
  1.5701 +	iError = aError;
  1.5702 +	PRINT((_L("CVDecTestEngine::MdvpoFatalError, FATAL ERROR [%d]"),aError))
  1.5703 +	iState = EStopped;
  1.5704 +	MdvpoStreamEnd();
  1.5705 +
  1.5706 +	iTestClass->MvdeSetError(aError);
  1.5707 +}
  1.5708 +
  1.5709 +
  1.5710 +/* ----------------------------------------------------------------------------
  1.5711 +* Name:       CVDecTestEngine::MdvpoInitComplete()
  1.5712 +* Purpose:    Completion of initialization is notified
  1.5713 +* Note:
  1.5714 +* Parameters: TInt aError
  1.5715 +* Return:     None
  1.5716 +* --------------------------------------------------------------------------*/
  1.5717 +
  1.5718 +void CVDecTestEngine::MdvpoInitComplete(TInt aError)
  1.5719 +{
  1.5720 +	PRINT((_L("CVDecTestEngine::MdvpoInitComplete, In")))
  1.5721 +	if ( iRunning )
  1.5722 +	{
  1.5723 +		PRINT((_L("CVDecTestEngine::MdvpoInitComplete, Stopping SchedulerWait")))
  1.5724 +		iScheduler->AsyncStop();
  1.5725 +		delete iScheduler;
  1.5726 +		iScheduler = NULL;
  1.5727 +		iMemDelete++;
  1.5728 +		#ifdef __MEM_CHECK_
  1.5729 +		PRINT((_L("CVDecTestEngine::MdvpoInitComplete, mem del, iScheduler") ))
  1.5730 +		#endif
  1.5731 +	}
  1.5732 +
  1.5733 +	if ( aError != KErrNone )
  1.5734 +	{
  1.5735 +		iError = aError;
  1.5736 +		PRINT((_L("CVDecTestEngine::MdvpoInitComplete, Error code [%d]"),aError))
  1.5737 +		return;
  1.5738 +	}
  1.5739 +
  1.5740 +	if (iDeleteDecoderFromInitComp)
  1.5741 +	{
  1.5742 +		//TearDown();
  1.5743 +		delete iDevvp;
  1.5744 +		iDevvp = NULL;
  1.5745 +		iMemDelete++;
  1.5746 +		#ifdef __MEM_CHECK_
  1.5747 +		PRINT((_L("CVDecTestEngine::MdvpoInitComplete, mem del, iDevvp") ))
  1.5748 +		#endif
  1.5749 +		iState = EStateNone;
  1.5750 +		PRINT((_L("CVDecTestEngine::MdvpoInitComplete,DevVideo deleted")))
  1.5751 +	}
  1.5752 +
  1.5753 +	iState = EInitialized;
  1.5754 +	PRINT((_L("CVDecTestEngine::MdvpoInitComplete, Initialized")))
  1.5755 +
  1.5756 +	//Initilize parameters for Decoding/Playback
  1.5757 +	iCodedInBuffer = NULL;
  1.5758 +	iOutBuffer =NULL;
  1.5759 +	iSentBuffCount = 0;
  1.5760 +	iReturnedBuffCount = 0;
  1.5761 +	iPictureLoss =0;
  1.5762 +	iInputEnd = EFalse;
  1.5763 +	iStreamEnd = EFalse;
  1.5764 +	iTimeStamp = 0;
  1.5765 +	iNoBuffAvailable = 0;
  1.5766 +
  1.5767 +	iTestClass->MvdeStreamEndReached();  // Notify observer data transfer is complete
  1.5768 +	PRINT((_L("CVDecTestEngine::MdvpoInitComplete, Out")))
  1.5769 +}
  1.5770 +
  1.5771 +
  1.5772 +/* ----------------------------------------------------------------------------
  1.5773 +* Name:       CVDecTestEngine::MdvpoStreamEnd()
  1.5774 +* Purpose:    End of stream is notified
  1.5775 +* Note:
  1.5776 +* Parameters: None
  1.5777 +* Return:     None
  1.5778 +* --------------------------------------------------------------------------*/
  1.5779 +
  1.5780 +void CVDecTestEngine::MdvpoStreamEnd()
  1.5781 +{
  1.5782 +	iStreamEnd = ETrue;
  1.5783 +	if (iOutBufferTemp)
  1.5784 +	{
  1.5785 +		iDevvp->ReturnPicture(iOutBufferTemp);
  1.5786 +	}
  1.5787 +	PRINT((_L("CVDecTestEngine::MdvpoStreamEnd(), Stream end")))
  1.5788 +
  1.5789 +	if (iFrameMeasurement && iFrameTime != 0)
  1.5790 +	{
  1.5791 +		TReal framerate = (TReal)(iReturnedBuffCount-1) / iFrameTime;
  1.5792 +		PRINT((_L("CVDecTestEngine::MdvpoStreamEnd(), Frame rate: [%f] fps"), framerate))
  1.5793 +	}
  1.5794 +	if(iInstantFpsEnabled)
  1.5795 +	{
  1.5796 +		TInt err = KErrNone;
  1.5797 +		for(TUint i=0; i < iInstantFpsList.Count(); i++ )
  1.5798 +		{
  1.5799 +			_LIT(KEnd, "\n");
  1.5800 +			TBuf8 <0x100> tempBuff;
  1.5801 +			TTimeIntervalMicroSeconds time = iInstantFpsList[ i ];
  1.5802 +			tempBuff.AppendNum((TInt64)time.Int64());
  1.5803 +			tempBuff.Append(KEnd);
  1.5804 +			err = iFpsFile.Write(tempBuff,tempBuff.Size() );
  1.5805 +			if( err != KErrNone )
  1.5806 +			{
  1.5807 +				PRINT((_L("CVDecTestEngine::MdvpoStreamEnd(), iFpsFile write error: [%d]"), err))
  1.5808 +			}
  1.5809 +		}
  1.5810 +	}
  1.5811 +	iTestClass->MvdeStreamEndReached();  // Notify observer data transfer is complete
  1.5812 +}
  1.5813 +
  1.5814 +/* ----------------------------------------------------------------------------
  1.5815 +* Name:       CVDecTestEngine::MmvbmoNewBuffers()
  1.5816 +* Purpose:    Observer callback in Custom interface Buffer management
  1.5817 +*             Client is notified a new buffer(s) is available
  1.5818 +* Note:       This is used when custom interface buffer management is used
  1.5819 +* Parameters: None
  1.5820 +* Return:     None
  1.5821 +* --------------------------------------------------------------------------*/
  1.5822 +
  1.5823 +#ifdef __CI_HEADERS__
  1.5824 +
  1.5825 +void CVDecTestEngine::MmvbmoNewBuffers()
  1.5826 +{
  1.5827 +
  1.5828 +	PRINT((_L("CVDecTestEngine::MmvbmoNewBuffers(), New input buffer is available")))
  1.5829 +	if ( (iState == ERunning) && iCIBuffMgmtOn )
  1.5830 +	{
  1.5831 +		iDecTestAO->RequestData();
  1.5832 +	}
  1.5833 +
  1.5834 +}
  1.5835 +#endif
  1.5836 +/* ----------------------------------------------------------------------------
  1.5837 +* Name:       CVDecTestEngine::MmvbmoReleaseBuffers()
  1.5838 +* Purpose:    Observer callback in Custom interface Buffer management
  1.5839 +*             Client is notified to release all buffers it has, using MmvbmReleaseBuffer
  1.5840 +* Note:       This is used when custom interface buffer management is used
  1.5841 +* Parameters: None
  1.5842 +* Return:     None
  1.5843 +* --------------------------------------------------------------------------*/
  1.5844 +#ifdef __CI_HEADERS__
  1.5845 +void CVDecTestEngine::MmvbmoReleaseBuffers()
  1.5846 +{
  1.5847 +	if (iRawInBuffer)
  1.5848 +	{
  1.5849 +		iCIBuffMgmt->MmvbmReleaseBuffer(iRawInBuffer);
  1.5850 +		iRawInBuffer = NULL;
  1.5851 +	}
  1.5852 +	PRINT((_L("CVDecTestEngine::MmvbmoReleaseBuffers(), buffer released")))
  1.5853 +}
  1.5854 +
  1.5855 +#endif
  1.5856 +
  1.5857 +/* ----------------------------------------------------------------------------
  1.5858 +* Name:       CVDecTestEngine::
  1.5859 +* Purpose:
  1.5860 +* Parameters: None
  1.5861 +* Return:     None
  1.5862 +* --------------------------------------------------------------------------*/
  1.5863 +#ifdef __RESOURCENOTIFICATION__
  1.5864 +void CVDecTestEngine::MmvroResourcesLost(TUid aMediaDevice)
  1.5865 +{
  1.5866 +	PRINT((_L("CVDecTestEngine::MmvroResourcesLost(), Uid [%x]"), aMediaDevice.iUid))
  1.5867 +
  1.5868 +	if (iDecoderUid.iUid != aMediaDevice.iUid)
  1.5869 +	{
  1.5870 +		PRINT((_L("CVDecTestEngine::MmvroResourcesLost, UID is different")))
  1.5871 +		return;
  1.5872 +	}
  1.5873 +
  1.5874 +	Pause();
  1.5875 +
  1.5876 +	iDecTestAO->Cancel();
  1.5877 +	if ( iDirectScreenAccess && iDsaStarted )
  1.5878 +	{
  1.5879 +		iDevvp->AbortDirectScreenAccess();
  1.5880 +		iDsaStarted = EFalse;
  1.5881 +		PRINT((_L("CVDecTestEngine::MmvroResourcesLost, DSA is aborted ")))
  1.5882 +	}
  1.5883 +
  1.5884 +
  1.5885 +	PRINT((_L("CVDecTestEngine::MmvroResourcesLost, Out ")))
  1.5886 +}
  1.5887 +#endif
  1.5888 +
  1.5889 +/* ----------------------------------------------------------------------------
  1.5890 +* Name:       CVDecTestEngine::
  1.5891 +* Purpose:
  1.5892 +* Parameters: None
  1.5893 +* Return:     None
  1.5894 +* --------------------------------------------------------------------------*/
  1.5895 +#ifdef __RESOURCENOTIFICATION__
  1.5896 +void CVDecTestEngine::MmvroResourcesRestored(TUid aMediaDevice)
  1.5897 +{
  1.5898 +	PRINT((_L("CVDecTestEngine::MmvroResourcesRestored(), Uid [%x]"), aMediaDevice.iUid))
  1.5899 +
  1.5900 +	if (iDecoderUid.iUid != aMediaDevice.iUid)
  1.5901 +	{
  1.5902 +		PRINT((_L("CVDecTestEngine::MmvroResourcesRestored, UID is different")))
  1.5903 +		return;
  1.5904 +	}
  1.5905 +
  1.5906 +	if ( iDirectScreenAccess && !iDsaStarted )
  1.5907 +	{
  1.5908 +		TRAPD(err, StartDirectScreenAccessL());
  1.5909 +		if (err != KErrNone)
  1.5910 +		{
  1.5911 +			PRINT((_L("CVDecTestEngine::MmvroResourcesRestored, couldn't start DSA, err[%d]"),err))
  1.5912 +			User::Leave(err);
  1.5913 +		}
  1.5914 +		else
  1.5915 +		{
  1.5916 +			PRINT((_L("CVDecTestEngine::MmvroResourcesRestored, DSA started")))
  1.5917 +		}
  1.5918 +	}
  1.5919 +
  1.5920 +
  1.5921 +	// Start DevVideoPlay
  1.5922 +	Resume();
  1.5923 +
  1.5924 +	PRINT((_L("CVDecTestEngine::MmvroResourcesRestored(), Out")))
  1.5925 +}
  1.5926 +
  1.5927 +#endif
  1.5928 +
  1.5929 +/* ----------------------------------------------------------------------------
  1.5930 +* Name:       CVDecTestAO::CVDecTestAO()
  1.5931 +* Purpose:    Constructor
  1.5932 +* Parameters: CVDecTestEngine* aTestEngine
  1.5933 +* Return:     None
  1.5934 +* --------------------------------------------------------------------------*/
  1.5935 +
  1.5936 +CVDecTestAO::CVDecTestAO(CVDecTestEngine* aTestEngine) :
  1.5937 +CActive(EPriorityStandard)
  1.5938 +{
  1.5939 +	iTestEngine = aTestEngine;
  1.5940 +	CActiveScheduler::Add(this);
  1.5941 +
  1.5942 +}
  1.5943 +
  1.5944 +
  1.5945 +/* ----------------------------------------------------------------------------
  1.5946 +* Name:       CVDecTestAO::~CVDecTestAO()
  1.5947 +* Purpose:    Deconstructor
  1.5948 +* Parameters: None
  1.5949 +* Return:     None
  1.5950 +* --------------------------------------------------------------------------*/
  1.5951 +
  1.5952 +CVDecTestAO::~CVDecTestAO()
  1.5953 +{
  1.5954 +
  1.5955 +	Cancel();
  1.5956 +
  1.5957 +}
  1.5958 +
  1.5959 +
  1.5960 +/* ----------------------------------------------------------------------------
  1.5961 +* Name:       CVDecTestAO::RequestData()
  1.5962 +* Purpose:    Asyncronous request of next input data
  1.5963 +* Parameters: None
  1.5964 +* Return:     None
  1.5965 +* --------------------------------------------------------------------------*/
  1.5966 +
  1.5967 +void CVDecTestAO::RequestData()
  1.5968 +{
  1.5969 +
  1.5970 +	if ( !IsActive() )
  1.5971 +	{
  1.5972 +		TRequestStatus* status = &iStatus;
  1.5973 +		User::RequestComplete(status, KErrNone);
  1.5974 +
  1.5975 +		SetActive();
  1.5976 +	}
  1.5977 +	else
  1.5978 +	{
  1.5979 +		PRINT((_L("CVDecTestAO::RequestData(), Async request already active")))
  1.5980 +	}
  1.5981 +}
  1.5982 +
  1.5983 +/* ----------------------------------------------------------------------------
  1.5984 +* Name:       CVDecTestAO::RunL()
  1.5985 +* Purpose:    Active object RunL
  1.5986 +* Parameters: None
  1.5987 +* Return:     None
  1.5988 +* --------------------------------------------------------------------------*/
  1.5989 +
  1.5990 +void CVDecTestAO::RunL()
  1.5991 +{
  1.5992 +	if (iTestEngine->iState == EPaused || iTestEngine->iState == EStopped)
  1.5993 +	{
  1.5994 +		return;
  1.5995 +	}
  1.5996 +	iTestEngine->HandleNewBufferL();
  1.5997 +}
  1.5998 +
  1.5999 +/* ----------------------------------------------------------------------------
  1.6000 +* Name:       CVDecTestAO::DoCancel()
  1.6001 +* Purpose:
  1.6002 +* Parameters: None
  1.6003 +* Return:     None
  1.6004 +* --------------------------------------------------------------------------*/
  1.6005 +
  1.6006 +
  1.6007 +void CVDecTestAO::DoCancel()
  1.6008 +{
  1.6009 +
  1.6010 +}
  1.6011 +
  1.6012 +/* ----------------------------------------------------------------------------
  1.6013 +* Name:       CVDecTestEngine::CorruptInput()
  1.6014 +* Purpose:    Make the input file corrupted to test codec's robustness
  1.6015 +* Note:
  1.6016 +* Parameters: None
  1.6017 +* Return:     None
  1.6018 +* --------------------------------------------------------------------------*/
  1.6019 +
  1.6020 +void CVDecTestEngine::CorruptInput(TInt aFilter, TInt aInterval,
  1.6021 +TInt aFrameNum, TInt aPct)
  1.6022 +{
  1.6023 +	PRINT((_L("CVDecTestEngine::CorruptInput(),In")))
  1.6024 +
  1.6025 +	iCorruptMarker = ETrue;
  1.6026 +	iCorruptCounter = 0;
  1.6027 +
  1.6028 +	iFilter = aFilter;
  1.6029 +	iInterval = aInterval;
  1.6030 +	iFrameNum = aFrameNum;
  1.6031 +	iPercentage = aPct;
  1.6032 +
  1.6033 +	PRINT((_L("CVDecTestEngine::CorruptInput(),Out")))
  1.6034 +}
  1.6035 +
  1.6036 +/* ----------------------------------------------------------------------------
  1.6037 +* Name:       CVDecTestEngine::CorruptEngine()
  1.6038 +* Purpose:    Make the content in the buffer corrupted
  1.6039 +* Note:
  1.6040 +* Parameters:
  1.6041 +* Return:     None
  1.6042 +* --------------------------------------------------------------------------*/
  1.6043 +
  1.6044 +void CVDecTestEngine::CorruptEngineL()
  1.6045 +{
  1.6046 +	PRINT((_L("CVDecTestEngine::CorruptEngin(), In")))
  1.6047 +	if( iInputEnd )
  1.6048 +	{
  1.6049 +		return;
  1.6050 +	}
  1.6051 +	if( iFrameCounter <= iInterval )
  1.6052 +	{
  1.6053 +		if( iFrameCounter < iInterval )
  1.6054 +		{
  1.6055 +			iFrameCounter++;
  1.6056 +			return;
  1.6057 +		}
  1.6058 +		else
  1.6059 +		{
  1.6060 +			iCorruptCounter++;
  1.6061 +		}
  1.6062 +	}
  1.6063 +	else
  1.6064 +	{
  1.6065 +		User::Leave( KErrGeneral);
  1.6066 +	}
  1.6067 +	TInt frameLength = iCodedInBuffer->iData.Size();
  1.6068 +	TInt maxLength = iCodedInBuffer->iData.MaxLength();
  1.6069 +
  1.6070 +	TUint8* memoryLocation = NULL;
  1.6071 +	TPtr8 tmpPointer(memoryLocation, frameLength, maxLength );
  1.6072 +	HBufC8* tempBuff = NULL;
  1.6073 +	tempBuff = HBufC8::NewL(iInBuffSize);
  1.6074 +	CleanupStack::PushL( tempBuff );
  1.6075 +	iMemAlloc++;
  1.6076 +	#ifdef __MEM_CHECK_
  1.6077 +	PRINT((_L("CVDecTestEngine::CorruptEngineL, mem alloc, tempBuff") ))
  1.6078 +	#endif
  1.6079 +	tmpPointer.Set(tempBuff->Des());
  1.6080 +
  1.6081 +	if( iFilter == 0 )
  1.6082 +	{
  1.6083 +		//Filter 0
  1.6084 +		PRINT((_L("CVDecTestEngine::CorruptEngin(),Filter 0, In")))
  1.6085 +
  1.6086 +
  1.6087 +		TInt lengthCopy = (TInt)( frameLength * iPercentage / 100 );
  1.6088 +
  1.6089 +
  1.6090 +		tmpPointer.Set(iCodedInBuffer->iData);
  1.6091 +
  1.6092 +		TInt corruptLength = frameLength - lengthCopy;
  1.6093 +		TInt corruptLen = 0;
  1.6094 +		for( TInt i = 0; i < corruptLength; i++ )
  1.6095 +		{
  1.6096 +			tmpPointer.Append('F');
  1.6097 +			corruptLen++;
  1.6098 +		}
  1.6099 +		PRINT((_L("CVDecTestEngine::CorruptEngin(),[%d] bytes are corrupted"), corruptLen ) )
  1.6100 +		iCodedInBuffer->iData.Set(tmpPointer);
  1.6101 +
  1.6102 +		PRINT((_L("CVDecTestEngine::CorruptEngin(),Filter 0, Out")))
  1.6103 +	}
  1.6104 +	else
  1.6105 +	{
  1.6106 +		// Filter 1
  1.6107 +		PRINT((_L("CVDecTestEngine::CorruptEngin(),Filter 1, In")))
  1.6108 +		// To be added here
  1.6109 +		TInt headerLen = 0;
  1.6110 +		if( iFrame == 0 )
  1.6111 +		{
  1.6112 +			headerLen = 16;
  1.6113 +
  1.6114 +		}
  1.6115 +		else
  1.6116 +		{
  1.6117 +			headerLen = 8;
  1.6118 +		}
  1.6119 +		TInt increment = (TInt)( ( frameLength - headerLen )/ ( ( frameLength - headerLen) * iPercentage / 100) ) - 1;
  1.6120 +
  1.6121 +		for(TInt i = headerLen; i < frameLength;  )
  1.6122 +		{
  1.6123 +
  1.6124 +			TUint8* memorySeg = NULL;
  1.6125 +			TPtr8 segCopy(memorySeg,increment);
  1.6126 +			HBufC8* segBuff = NULL;
  1.6127 +			segBuff = HBufC8::NewL( increment );
  1.6128 +			#ifdef __MEM_CHECK_
  1.6129 +			PRINT((_L("CVDecTestEngine::CorruptEngine, mem alloc, segBuff") ))
  1.6130 +			#endif
  1.6131 +			iMemAlloc++;
  1.6132 +
  1.6133 +			CleanupStack::PushL( segBuff );
  1.6134 +			segCopy.Set(segBuff->Des());
  1.6135 +
  1.6136 +			if( i < frameLength - increment - 1 )
  1.6137 +			{
  1.6138 +				segCopy = iCodedInBuffer->iData.MidTPtr(i, increment );
  1.6139 +				segCopy.Append('F');
  1.6140 +				i++;
  1.6141 +				PRINT((_L("CVDecTestEngine::CorruptEngin(),[%d]th byte is corrupted"), i ) )
  1.6142 +				tmpPointer.Append( segCopy );
  1.6143 +				i += increment;
  1.6144 +			}
  1.6145 +			else // end of the frame
  1.6146 +			{
  1.6147 +				segCopy = iCodedInBuffer->iData.MidTPtr(i, (frameLength - i) );
  1.6148 +				tmpPointer.Append( segCopy );
  1.6149 +				i = frameLength;
  1.6150 +			}
  1.6151 +
  1.6152 +			CleanupStack::PopAndDestroy( segBuff );
  1.6153 +			iMemDelete++;
  1.6154 +			#ifdef __MEM_CHECK_
  1.6155 +			PRINT((_L("CVDecTestEngine::CorruptEngine, mem del, segBuff") ))
  1.6156 +			#endif
  1.6157 +		}
  1.6158 +		iCodedInBuffer->iData.Set(tmpPointer);
  1.6159 +
  1.6160 +		PRINT((_L("CVDecTestEngine::CorruptEngin(),Filter 1, Out")))
  1.6161 +	}
  1.6162 +	if( iCorruptCounter == iFrameNum )
  1.6163 +	{
  1.6164 +		iFrameCounter = 0;
  1.6165 +		iCorruptCounter = 0;
  1.6166 +	}
  1.6167 +	CleanupStack::PopAndDestroy( tempBuff );
  1.6168 +	iMemDelete++;
  1.6169 +	#ifdef __MEM_CHECK_
  1.6170 +	PRINT((_L("CVDecTestEngine::CorruptEngine, mem del, tempBuff") ))
  1.6171 +	#endif
  1.6172 +	PRINT((_L("CVDecTestEngine::CorruptEngin(), Out")))
  1.6173 +}
  1.6174 +
  1.6175 +
  1.6176 +/* ----------------------------------------------------------------------------
  1.6177 +* Name:       CVDecTestEngine::CorruptEngineL(TVideoInputBuffer*
  1.6178 +aCodedInBuffer)
  1.6179 +* Purpose:    Make the content in the buffer corrupted
  1.6180 +* Note:
  1.6181 +* Parameters: TVideoInputBuffer* aCodedInBuffer
  1.6182 +* Return:     None
  1.6183 +* --------------------------------------------------------------------------*/
  1.6184 +
  1.6185 +void CVDecTestEngine::CorruptEngineL( TVideoInputBuffer* aCodedInBuffer )
  1.6186 +{
  1.6187 +	PRINT((_L("CVDecTestEngine::CorruptEngin(TVideoInputBuffer* aCodedInBuffer), In")))
  1.6188 +	iFrameWriteLength = aCodedInBuffer->iData.Length();
  1.6189 +	if( iInputEnd )
  1.6190 +	{
  1.6191 +		return;
  1.6192 +	}
  1.6193 +	if( iFrameCounter <= iInterval )
  1.6194 +	{
  1.6195 +		if( iFrameCounter < iInterval )
  1.6196 +		{
  1.6197 +			iFrameCounter++;
  1.6198 +			PRINT((_L("CVDecTestEngine::CorruptEngin(TVideoInputBuffer* aCodedInBuffer), Out")))
  1.6199 +			return;
  1.6200 +		}
  1.6201 +		else
  1.6202 +		{
  1.6203 +			iCorruptCounter++;
  1.6204 +		}
  1.6205 +	}
  1.6206 +	else
  1.6207 +	{
  1.6208 +		User::Leave( KErrGeneral);
  1.6209 +	}
  1.6210 +
  1.6211 +	TInt frameLength = aCodedInBuffer->iData.Size();
  1.6212 +	TInt maxLength = aCodedInBuffer->iData.MaxLength();
  1.6213 +
  1.6214 +	TUint8* memoryLocation = NULL;
  1.6215 +	TPtr8 tmpPointer(memoryLocation, frameLength, maxLength );
  1.6216 +	HBufC8* tempBuff = NULL;
  1.6217 +	tempBuff = HBufC8::NewL(iInBuffSize);
  1.6218 +	iMemAlloc++;
  1.6219 +	CleanupStack::PushL( tempBuff );
  1.6220 +	#ifdef __MEM_CHECK_
  1.6221 +	PRINT((_L("CVDecTestEngine::CorruptEngine, mem alloc, tempBuff") ))
  1.6222 +	#endif
  1.6223 +	tmpPointer.Set(tempBuff->Des());
  1.6224 +
  1.6225 +	if( iFilter == 0 )
  1.6226 +	{
  1.6227 +		//Filter 0
  1.6228 +		PRINT((_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),Filter 0, In")))
  1.6229 +		tmpPointer.Set( aCodedInBuffer->iData );
  1.6230 +		PRINT((_L("Length of tmpPointer, %d"), tmpPointer.Length() ) )
  1.6231 +
  1.6232 +		TInt corruptLength = (TInt)( ( frameLength - 8 )* iPercentage / 100 );
  1.6233 +
  1.6234 +		TInt copyLength = frameLength - corruptLength;
  1.6235 +
  1.6236 +		TInt corruptLen = 0;
  1.6237 +
  1.6238 +		for( TInt i = copyLength; i < frameLength; i++ )
  1.6239 +		{
  1.6240 +			// Corrupt the byte by chaning its value instead of setting "zero"
  1.6241 +			if( tmpPointer[i] < 0x05 )
  1.6242 +			{
  1.6243 +				tmpPointer[i] += 0x05;
  1.6244 +			}
  1.6245 +			else
  1.6246 +			{
  1.6247 +				tmpPointer[i] -= 0x05;
  1.6248 +			}
  1.6249 +			corruptLen++;
  1.6250 +		}
  1.6251 +		PRINT((_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),[%d] bytes are corrupted"), corruptLen ) )
  1.6252 +
  1.6253 +		PRINT((_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),Filter 0, Out")))
  1.6254 +	}
  1.6255 +	else if( iFilter == 1)
  1.6256 +	{
  1.6257 +		// Filter 1
  1.6258 +		PRINT((_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),Filter 1, In")))
  1.6259 +		tmpPointer.Set( aCodedInBuffer->iData );
  1.6260 +		PRINT((_L("Length of tmpPointer, %d"), tmpPointer.Length() ) )
  1.6261 +		// To be added here
  1.6262 +		// first 8 bytes of each frame should not be corrupted
  1.6263 +		TInt headerLen = 8;
  1.6264 +
  1.6265 +		TInt increment = (TInt)( ( frameLength - headerLen )/ ( ( frameLength - headerLen) * iPercentage / 100) ) - 1;
  1.6266 +		TInt corruptLen = 0;
  1.6267 +		for(TInt i = headerLen + 1; i < frameLength;  i += increment)
  1.6268 +		{
  1.6269 +			// Corrupt the byte by chaning its value instead of setting "zero"
  1.6270 +			if( tmpPointer[i] < 0x05 )
  1.6271 +			{
  1.6272 +				tmpPointer[i] += 0x05;
  1.6273 +			}
  1.6274 +			else
  1.6275 +			{
  1.6276 +				tmpPointer[i] -= 0x05;
  1.6277 +			}
  1.6278 +			// tmpPointer[i] = 0x00;
  1.6279 +			corruptLen ++;
  1.6280 +		}
  1.6281 +		PRINT((_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),[%d] bytes are corrupted"), corruptLen ) )
  1.6282 +
  1.6283 +		PRINT(_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),Filter 1, Out"))
  1.6284 +	}
  1.6285 +	else if( iFilter == 2)
  1.6286 +	{
  1.6287 +		PRINT(_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),Filter 2, In"))
  1.6288 +		tmpPointer.Set( aCodedInBuffer->iData );
  1.6289 +		PRINT((_L("Length of tmpPointer, %d"), tmpPointer.Length() ) )
  1.6290 +
  1.6291 +		TInt corruptLength = (TInt)( ( frameLength - 8 )* iPercentage / 100 );
  1.6292 +
  1.6293 +		//TInt copyLength = frameLength - corruptLength;
  1.6294 +		iFrameWriteLength -= corruptLength;
  1.6295 +		PRINT((_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),[%d] bytes are removed"), corruptLength ) )
  1.6296 +		// Modify the framesize value in the frame header
  1.6297 +		TUint32 finalSize = (TUint32)( iFrameWriteLength - 8 );
  1.6298 +		for( TInt i = 0; i < 3; i++ )
  1.6299 +		{
  1.6300 +			tmpPointer[i] = (TUint8) ( (  finalSize & ( (0x000000ff)<<(8*i) ) )>> (i*8) );
  1.6301 +		}
  1.6302 +		/* the above assignment equals followings
  1.6303 +		tmpPointer[0] = (TUint8)( finalSize & ~(0xffffff00) );
  1.6304 +		tmpPointer[1] = (TUint8)( ( finalSize & ~(0xffff00ff))>>8 );
  1.6305 +		tmpPointer[2] = (TUint8)( ( finalSize & ~(0xff00ffff))>>16 );
  1.6306 +		*/
  1.6307 +
  1.6308 +		PRINT(_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),Filter 2, Out"))
  1.6309 +	}
  1.6310 +	else      // iFilter == 3
  1.6311 +	{
  1.6312 +		PRINT(_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),Filter 3, In"))
  1.6313 +		tmpPointer.Set( aCodedInBuffer->iData );
  1.6314 +		TInt corruptLength = (TInt)( ( frameLength - 8 )* iPercentage / 100 );
  1.6315 +
  1.6316 +		//TInt copyLength = frameLength - corruptLength;
  1.6317 +		iFrameWriteLength -= corruptLength;
  1.6318 +		// Modify the framesize value in the frame header
  1.6319 +		TUint32 finalSize = (TUint32)( iFrameWriteLength - 8 );
  1.6320 +		for( TInt i = 0; i < 3; i++ )
  1.6321 +		{
  1.6322 +
  1.6323 +			tmpPointer[i] = (TUint8) ( (  finalSize & ( (0x000000ff)<<(8*i) ) )>> (i*8) );
  1.6324 +		}
  1.6325 +		TInt headerLen = 8;
  1.6326 +		// Copy the other bytes for the header
  1.6327 +		for( TInt i = 3; i < headerLen; i++ )
  1.6328 +		{
  1.6329 +
  1.6330 +			tmpPointer[i] = aCodedInBuffer->iData[i];
  1.6331 +		}
  1.6332 +		TInt increment = (TInt)( ( frameLength - headerLen )/ ( ( frameLength - headerLen) * iPercentage / 100) ) - 1;
  1.6333 +		TInt incrementCounter = 0;
  1.6334 +		TInt byteCounter = 0;
  1.6335 +		TInt j = headerLen;
  1.6336 +		for( TInt i = headerLen; i < iFrameWriteLength; i++ )
  1.6337 +		{
  1.6338 +
  1.6339 +			// metadata assignment
  1.6340 +			tmpPointer[i] = aCodedInBuffer->iData[j];
  1.6341 +			if( byteCounter < corruptLength )
  1.6342 +			{
  1.6343 +				incrementCounter++;
  1.6344 +			}
  1.6345 +
  1.6346 +			j++;
  1.6347 +			if( incrementCounter == increment )
  1.6348 +			{
  1.6349 +				j++;
  1.6350 +				incrementCounter = 0;
  1.6351 +				byteCounter++;
  1.6352 +			}
  1.6353 +		}
  1.6354 +
  1.6355 +
  1.6356 +		PRINT(_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer),Filter 3, Out"))
  1.6357 +	}
  1.6358 +
  1.6359 +
  1.6360 +
  1.6361 +	aCodedInBuffer->iData.Set(tmpPointer);
  1.6362 +	if( iCorruptCounter == iFrameNum )
  1.6363 +	{
  1.6364 +		iFrameCounter = 0;
  1.6365 +		iCorruptCounter = 0;
  1.6366 +	}
  1.6367 +	CleanupStack::PopAndDestroy( tempBuff );
  1.6368 +	iMemDelete++;
  1.6369 +	#ifdef __MEM_CHECK_
  1.6370 +	PRINT((_L("CVDecTestEngine::CorrupEngineL, mem del, tempBuff") ))
  1.6371 +	#endif
  1.6372 +	PRINT((_L("CorruptEngineL(TVideoInputBuffer* aCodedInBuffer), Out")))
  1.6373 +}
  1.6374 +
  1.6375 +
  1.6376 +
  1.6377 +/* ----------------------------------------------------------------------------
  1.6378 +* Name:       CVDecTestEngine::CreateCorruptedFile()
  1.6379 +* Purpose:    Make the content in the buffer corrupted and output to a file
  1.6380 +* Note:
  1.6381 +* Parameters:
  1.6382 +* Return:     None
  1.6383 +* --------------------------------------------------------------------------*/
  1.6384 +
  1.6385 +TInt CVDecTestEngine::CreateCorruptedFileL()
  1.6386 +{
  1.6387 +	PRINT((_L("CVDecTestEngine::CreateCorruptedFileL, In")));
  1.6388 +	// Only support VC-1 decoder
  1.6389 +
  1.6390 +	// make new buffer for the data read from the file
  1.6391 +	HBufC8* tmpBuff = NULL;
  1.6392 +
  1.6393 +	TVideoInputBuffer* codedBuffer = new(ELeave) TVideoInputBuffer;
  1.6394 +	CleanupStack::PushL( codedBuffer );
  1.6395 +
  1.6396 +	tmpBuff = HBufC8::NewL(iInBuffSize);
  1.6397 +	CleanupStack::PushL( tmpBuff );
  1.6398 +	codedBuffer->iData.Set(tmpBuff->Des());
  1.6399 +	// read content of the file in the buffer
  1.6400 +	TInt err = 0;
  1.6401 +
  1.6402 +	TInt frameDropNumCounter = 0;
  1.6403 +	while ( !iInputEnd )
  1.6404 +	{
  1.6405 +		// Read the VC1 input video from the very beginning
  1.6406 +		if( iCodecType == EVC1)
  1.6407 +		{
  1.6408 +			err = ReadVC1FrameL( codedBuffer );
  1.6409 +		}
  1.6410 +		else if( iCodecType == EMPEG4 )
  1.6411 +		{
  1.6412 +			err = ReadMPEG4FrameL( codedBuffer );
  1.6413 +		}
  1.6414 +		else
  1.6415 +		{
  1.6416 +
  1.6417 +		}
  1.6418 +
  1.6419 +
  1.6420 +		if( err < 0)
  1.6421 +		{
  1.6422 +			PRINT((_L("CVDecTestEngine::CreateCorruptedFileL, Error reading file") ))
  1.6423 +			return KErrGeneral;
  1.6424 +		}
  1.6425 +		if( err == 0 )
  1.6426 +		{
  1.6427 +			PRINT((_L("CVDecTestEngine::LoadNextFrameL, End of file is found") ))
  1.6428 +			break;
  1.6429 +		}
  1.6430 +		else
  1.6431 +		{
  1.6432 +			// the frame is successfully read and ready to be corrupted
  1.6433 +
  1.6434 +			// make some bytes corrupted
  1.6435 +			if( !iFrameDropMarker )
  1.6436 +			{
  1.6437 +				CorruptEngineL( codedBuffer );
  1.6438 +				PRINT((_L("Corruption is done")));
  1.6439 +			}
  1.6440 +		}
  1.6441 +
  1.6442 +		// Prepare a buffer for copying the bytes from the frame buffer
  1.6443 +		/*
  1.6444 +		TInt copyLen = codedBuffer->iData.Size();
  1.6445 +
  1.6446 +		TUint8* memorySeg = NULL;
  1.6447 +		TPtr8 segCopy(memorySeg,copyLen);
  1.6448 +		HBufC8* segBuff = NULL;
  1.6449 +		segBuff = HBufC8::NewL( copyLen );
  1.6450 +		CleanupStack::PushL( segBuff );
  1.6451 +		segCopy.Set(segBuff->Des());
  1.6452 +		*/
  1.6453 +		if( iFrameDropMarker )
  1.6454 +		{
  1.6455 +			iFrameWriteLength = codedBuffer->iData.Length();
  1.6456 +			// drop the frame specified by the user
  1.6457 +			if( iFrameDropCounter < iFrameDropInterval )
  1.6458 +			{
  1.6459 +				PRINT((_L("CVDecTestEngine::CreateCorruptedFileL,iFrameWriteLength [%d]"), iFrameWriteLength ) )
  1.6460 +				err = iOutCorruptedFile.Write(codedBuffer->iData, iFrameWriteLength );
  1.6461 +				PRINT((_L("Output to the file for frame drop successful")));
  1.6462 +				if ( err!= KErrNone )
  1.6463 +				{
  1.6464 +					PRINT((_L("Output corrupted File write Failed")));
  1.6465 +					iOutCorruptedFile.Close();
  1.6466 +				}
  1.6467 +
  1.6468 +
  1.6469 +
  1.6470 +			}
  1.6471 +			else
  1.6472 +			{
  1.6473 +				frameDropNumCounter++;
  1.6474 +				PRINT((_L("Frame is dropped!")));
  1.6475 +			}
  1.6476 +
  1.6477 +			if( frameDropNumCounter == iFrameDropNum )
  1.6478 +			{
  1.6479 +				iFrameDropCounter = 0;
  1.6480 +				frameDropNumCounter = 0;
  1.6481 +			}
  1.6482 +		}
  1.6483 +		else //write corrupted frame to the file
  1.6484 +		{
  1.6485 +			// Prepare a buffer for copying the bytes from the frame buffer
  1.6486 +			/*         TInt copyLen = codedBuffer->iData.Size();
  1.6487 +
  1.6488 +			TUint8* memorySeg = NULL;
  1.6489 +			TPtr8 segCopy(memorySeg,copyLen);
  1.6490 +			HBufC8* segBuff = NULL;
  1.6491 +			segBuff = HBufC8::NewL( copyLen );
  1.6492 +			CleanupStack::PushL( segBuff );
  1.6493 +			segCopy.Set(segBuff->Des());
  1.6494 +
  1.6495 +			*/
  1.6496 +			PRINT((_L("CVDecTestEngine::CreateCorruptedFileL,iFrameWriteLength [%d]"), iFrameWriteLength ) )
  1.6497 +			err = iOutCorruptedFile.Write(codedBuffer->iData, iFrameWriteLength );
  1.6498 +
  1.6499 +			if ( err!= KErrNone )
  1.6500 +			{
  1.6501 +				PRINT((_L("Output corrupted File write Failed")));
  1.6502 +				iOutCorruptedFile.Close();
  1.6503 +			}
  1.6504 +			PRINT((_L("Output corrupted File is successful")));
  1.6505 +
  1.6506 +		}
  1.6507 +
  1.6508 +	}
  1.6509 +	iOutCorruptedFile.Close();
  1.6510 +	CleanupStack::PopAndDestroy( tmpBuff );
  1.6511 +	CleanupStack::PopAndDestroy( codedBuffer );
  1.6512 +	PRINT((_L("CVDecTestEngine::CreateCorruptedFileL, Out")));
  1.6513 +	return KErrNone;
  1.6514 +}
  1.6515 +
  1.6516 +/* ----------------------------------------------------------------------------
  1.6517 +* Name:       CVDecTestEngine::OpenFileToWriteL()
  1.6518 +* Purpose:    Open output File To Write
  1.6519 +* Note:       Memory buffer output is used
  1.6520 +* Parameters: TFileName& aOutFileName
  1.6521 +* Return:     None
  1.6522 +* --------------------------------------------------------------------------*/
  1.6523 +
  1.6524 +
  1.6525 +void CVDecTestEngine::OpenFileToWriteL(TFileName& aInFileName)
  1.6526 +{
  1.6527 +	PRINT((_L("CVDecTestEngine::OpenFileToWrite, In")));
  1.6528 +	TInt err = KErrNone;
  1.6529 +
  1.6530 +	iOutCorruptedFileName.Copy(aInFileName);
  1.6531 +
  1.6532 +	err = iOutCorruptedFile.Replace(iFs, iOutCorruptedFileName, EFileShareExclusive|EFileWrite);
  1.6533 +
  1.6534 +	iOutCorruptedFileOpen = ETrue;
  1.6535 +
  1.6536 +
  1.6537 +	if ( err!= KErrNone )
  1.6538 +	{
  1.6539 +		PRINT((_L("CVDecTestEngine::OpenFileToWrite, Output corrupted File Replace Failed")));
  1.6540 +		iOutCorruptedFile.Close();
  1.6541 +	}
  1.6542 +
  1.6543 +	AssertTIntEqualL(KErrNone,err);
  1.6544 +	PRINT((_L("CVDecTestEngine::OpenFileToWrite, Out")));
  1.6545 +}
  1.6546 +
  1.6547 +
  1.6548 +/* ----------------------------------------------------------------------------
  1.6549 +* Name:       CVDecTestEngine::ReadVC1FrameL()
  1.6550 +* Purpose:
  1.6551 +* Note:
  1.6552 +* Parameters: None
  1.6553 +* Return:     None
  1.6554 +* --------------------------------------------------------------------------*/
  1.6555 +
  1.6556 +TInt CVDecTestEngine::ReadVC1FrameL(TVideoInputBuffer* aCodedInBuffer)
  1.6557 +{
  1.6558 +	// Note: this function is used as part of corrupt engine to make input
  1.6559 +	// VC1 video corrupted for codec robustness test
  1.6560 +	// Reading VC1 input video from the very beginning of the file
  1.6561 +	PRINT((_L("CVDecTestEngine::ReadVC1FrameL, In")));
  1.6562 +	unsigned int frameDataSize = 4;     //4 Bytes to obain the framesize
  1.6563 +	unsigned int frameSize=0;
  1.6564 +	unsigned int Timestamp;
  1.6565 +	TInt err = 0;
  1.6566 +	TUint8* ptr = new (ELeave) TUint8[frameDataSize];
  1.6567 +	iMemAlloc++;
  1.6568 +	#ifdef __MEM_CHECK_
  1.6569 +	PRINT((_L("CVDecTestEngine::ReadVC1FrameL, mem alloc, ptr") ))
  1.6570 +	#endif
  1.6571 +	TPtr8 frameData(ptr, frameDataSize);
  1.6572 +	if ( (err = iInFile.Read(frameData, frameDataSize)) != KErrNone)
  1.6573 +	{
  1.6574 +		PRINT((_L("CVDecTestEngine::ReadVC1FrameL, Error reading file") ))
  1.6575 +		return err;
  1.6576 +	}
  1.6577 +
  1.6578 +	if (frameData.Length() < 4)
  1.6579 +	{
  1.6580 +		PRINT((_L("CVDecTestEngine::ReadVC1FrameL, File end found") ))
  1.6581 +		aCodedInBuffer->iData.SetLength( 0 );
  1.6582 +		delete ptr;
  1.6583 +		ptr = NULL;
  1.6584 +		iMemDelete++;
  1.6585 +		iInputEnd = ETrue;
  1.6586 +		return KErrNone;
  1.6587 +	}
  1.6588 +
  1.6589 +	PRINT((_L("CVDecTestEngine::ReadVC1FrameL, Reading Item") ))
  1.6590 +	ReadItemLE(ptr, 4, (TUint8 *)&frameSize);
  1.6591 +	PRINT((_L("CVDecTestEngine::ReadVC1FrameL, before AND frameSize: %x"), frameSize ))
  1.6592 +
  1.6593 +	//RCV_V2_FRAMESIZE_FLAGS
  1.6594 +	frameSize = frameSize & ~(0xff000000);
  1.6595 +
  1.6596 +	PRINT((_L("CVDecTestEngine::ReadVC1FrameL, frameSize: %d"), frameSize ))
  1.6597 +
  1.6598 +	//Now obtain the Timestamp of the frame
  1.6599 +	if ( (err = iInFile.Read(frameData, frameDataSize)) != KErrNone)
  1.6600 +	{
  1.6601 +		PRINT((_L("CVDecTestEngine::ReadVC1FrameL, Error reading file %d"), err ))
  1.6602 +		return err;
  1.6603 +	}
  1.6604 +
  1.6605 +	PRINT((_L("CVDecTestEngine::ReadVC1FrameL, Reading Item2") ))
  1.6606 +	ReadItemLE(ptr, 4, (TUint8 *)&Timestamp);
  1.6607 +	PRINT((_L("CVDecTestEngine::ReadVC1FrameL, Timestamp: %d"), Timestamp ))
  1.6608 +	delete ptr;
  1.6609 +	iMemDelete++;
  1.6610 +	#ifdef __MEM_CHECK_
  1.6611 +	PRINT((_L("CVDecTestEngine::ReadVC1FrameL, mem del, ptr") ))
  1.6612 +	#endif
  1.6613 +	if (frameSize != 0)
  1.6614 +	{
  1.6615 +		//Send metadata in the first frame
  1.6616 +		if (iFrame==0)
  1.6617 +		{
  1.6618 +			PRINT((_L("CVDecTestEngine::ReadVC1FrameL, iFrame num == 0, %d"), iFrame ))
  1.6619 +			TInt pos = - ( KVc1HeaderLength + 8 );  // assume the codec is configured
  1.6620 +			err = iInFile.Seek(ESeekCurrent,pos);
  1.6621 +
  1.6622 +			// header length is 36, KVc1HeaderLength = 36
  1.6623 +			PRINT((_L("CVDecTestEngine::ReadVC1FrameL, file header, 36 bytes")))
  1.6624 +			if ( (err = iInFile.Read(aCodedInBuffer->iData, KVc1HeaderLength)) != KErrNone)
  1.6625 +			{
  1.6626 +				PRINT((_L("CVDecTestEngine::ReadVC1FrameL, Error reading file %d"), err ))
  1.6627 +				return err;
  1.6628 +			}
  1.6629 +
  1.6630 +		}
  1.6631 +		else
  1.6632 +		{
  1.6633 +			PRINT((_L("CVDecTestEngine::ReadVC1FrameL, iFrame num = %d"), iFrame ))
  1.6634 +			TInt pos = -8;
  1.6635 +			err = iInFile.Seek(ESeekCurrent, pos);
  1.6636 +			PRINT((_L("CVDecTestEngine::ReadVC1FrameL, read file: %d"), err ))
  1.6637 +			if ( (err = iInFile.Read(aCodedInBuffer->iData, frameSize+8)) != KErrNone)
  1.6638 +			{
  1.6639 +				PRINT((_L("CVDecTestEngine::ReadVC1FrameL, Error reading file %d"), err ))
  1.6640 +				return err;
  1.6641 +			}
  1.6642 +		}
  1.6643 +
  1.6644 +		TInt currentPos = 0;
  1.6645 +		iInFile.Seek(ESeekCurrent, currentPos );
  1.6646 +		PRINT((_L("CVDecTestEngine::ReadVC1FrameL, currentPos %d"), currentPos ))
  1.6647 +		currentPos = 0;
  1.6648 +
  1.6649 +		/*	Not necessary
  1.6650 +		aCodedInBuffer->iSequenceNumber = iFrame;
  1.6651 +		aCodedInBuffer->iOptions = TVideoInputBuffer::EPresentationTimestamp;
  1.6652 +
  1.6653 +		aCodedInBuffer->iPresentationTimestamp = Timestamp;
  1.6654 +		iTimeToPlay = aCodedInBuffer->iPresentationTimestamp ;
  1.6655 +
  1.6656 +
  1.6657 +		aCodedInBuffer->iDecodingTimestamp = Timestamp;
  1.6658 +		iPresentationTimestamp = aCodedInBuffer->iPresentationTimestamp ;
  1.6659 +		*/
  1.6660 +
  1.6661 +
  1.6662 +	}
  1.6663 +
  1.6664 +	iFrame++;
  1.6665 +	iFrameDropCounter++;
  1.6666 +	PRINT(_L("CVDecTestEngine::ReadVC1FrameL.. Out"));
  1.6667 +	return frameSize;
  1.6668 +}
  1.6669 +
  1.6670 +
  1.6671 +
  1.6672 +/* ----------------------------------------------------------------------------
  1.6673 +* Name:       CVDecTestEngine::ReadMPEG4FrameL()
  1.6674 +* Purpose:
  1.6675 +* Note:
  1.6676 +* Parameters: None
  1.6677 +* Return:     None
  1.6678 +* --------------------------------------------------------------------------*/
  1.6679 +
  1.6680 +TInt CVDecTestEngine::ReadMPEG4FrameL(TVideoInputBuffer* aCodedInBuffer)
  1.6681 +{
  1.6682 +	// Note: this function is used as part of corrupt engine to make input
  1.6683 +	// MPEG4 video corrupted for codec robustness test
  1.6684 +	// Reading MPEG4 input video from the very beginning of the file
  1.6685 +	PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, In")));
  1.6686 +	TInt buffLength = iInBuffSize;
  1.6687 +
  1.6688 +	//TUint8* testData =NULL;
  1.6689 +	TInt err = KErrNone;
  1.6690 +
  1.6691 +	if ( aCodedInBuffer->iData.MaxLength() < buffLength )
  1.6692 +	{
  1.6693 +		err = KErrOverflow;
  1.6694 +		PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, Buffer is small, [%d]Byte"),aCodedInBuffer->iData.MaxLength()))
  1.6695 +		return err;
  1.6696 +	}
  1.6697 +
  1.6698 +	aCodedInBuffer->iData.SetLength(0);
  1.6699 +
  1.6700 +	//Buffer is not full,  reset size of buffer
  1.6701 +	if ( aCodedInBuffer->iData.Length() < buffLength)
  1.6702 +	{
  1.6703 +		buffLength = aCodedInBuffer->iData.Length();
  1.6704 +	}
  1.6705 +
  1.6706 +
  1.6707 +
  1.6708 +	TInt pos = 0;
  1.6709 +	TBool found = EFalse;
  1.6710 +	TBool firstStartCode = EFalse;
  1.6711 +	//TUint8 byte = 0;
  1.6712 +	TInt currentPos = 0;
  1.6713 +	iInFile.Seek(ESeekCurrent, currentPos );
  1.6714 +	if( currentPos != 0 && currentPos == iCurrentFilePos )
  1.6715 +	{
  1.6716 +		iInputEnd = ETrue;
  1.6717 +	}
  1.6718 +	else
  1.6719 +	{
  1.6720 +		iCurrentFilePos = currentPos;
  1.6721 +	}
  1.6722 +	PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, currentPos %d"), currentPos ))
  1.6723 +	while (!iInputEnd && !found)
  1.6724 +	{
  1.6725 +		TInt zeroCounter = 0;
  1.6726 +		err = iInFile.Read(aCodedInBuffer->iData, 1 ); // read one byte
  1.6727 +		if( aCodedInBuffer->iData.Length() == 0 )
  1.6728 +		{
  1.6729 +			pos++;
  1.6730 +			iInputEnd = ETrue;
  1.6731 +			break;
  1.6732 +		}
  1.6733 +
  1.6734 +		while( aCodedInBuffer->iData[0] == 0x00 && !iInputEnd )
  1.6735 +		{
  1.6736 +			zeroCounter++;
  1.6737 +			pos++;
  1.6738 +			err = iInFile.Read(aCodedInBuffer->iData, 1 ); // read one byte
  1.6739 +		}
  1.6740 +		pos++;
  1.6741 +		if ((zeroCounter >= 2) && (aCodedInBuffer->iData[0] == 0x01))
  1.6742 +		{
  1.6743 +			//byte = ReadByteFromFile();
  1.6744 +			err = iInFile.Read(aCodedInBuffer->iData, 1 ); // read one byte
  1.6745 +			//PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, iData %d, f2"), aCodedInBuffer->iData[0] ))
  1.6746 +			pos++;
  1.6747 +			//if (byte == 0xB6 && !firstStartCode)
  1.6748 +			if( aCodedInBuffer->iData[0] == 0xB6 && !firstStartCode )
  1.6749 +			{
  1.6750 +				firstStartCode = ETrue;
  1.6751 +			}
  1.6752 +			//else if (byte != 0xB1 && firstStartCode)
  1.6753 +			else if( aCodedInBuffer->iData[0]!= 0xB1 && firstStartCode )
  1.6754 +			{
  1.6755 +				PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, end of mpeg-4 picture found [%d]"), pos-4))
  1.6756 +				found = ETrue;
  1.6757 +			}
  1.6758 +		}
  1.6759 +	}
  1.6760 +	PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, pos (read length), %d"), pos))
  1.6761 +	TInt backward = 0 - pos;
  1.6762 +	err = iInFile.Seek(ESeekCurrent, backward );// go back
  1.6763 +
  1.6764 +	if( err != KErrNone)
  1.6765 +	{
  1.6766 +		PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, Error seeking file %d"), err ))
  1.6767 +		return err;
  1.6768 +	}
  1.6769 +
  1.6770 +	if (iInputEnd)
  1.6771 +	{
  1.6772 +		PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, inputEndFound, %d"), pos))
  1.6773 +		pos--;
  1.6774 +	}
  1.6775 +	else
  1.6776 +	{
  1.6777 +		pos -= 4;
  1.6778 +	}
  1.6779 +
  1.6780 +
  1.6781 +	currentPos = 0;
  1.6782 +	err = iInFile.Seek( ESeekCurrent, currentPos);
  1.6783 +	PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, position goes back to the beginning, %d"), currentPos))
  1.6784 +	if ( (err = iInFile.Read(aCodedInBuffer->iData, pos )) != KErrNone)
  1.6785 +	{
  1.6786 +		PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, Error reading file %d"), err ))
  1.6787 +		return err;
  1.6788 +	}
  1.6789 +	if( aCodedInBuffer->iData.Length() < 4 )
  1.6790 +	{
  1.6791 +		iInputEnd = ETrue;
  1.6792 +	}
  1.6793 +	iFrameDropCounter++;
  1.6794 +	iFrame++;
  1.6795 +	PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, iFrameDropCounter, %d"), iFrameDropCounter))
  1.6796 +	PRINT((_L("CVDecTestEngine::ReadMPEG4FrameL, Out")));
  1.6797 +	return pos;
  1.6798 +}
  1.6799 +
  1.6800 +/* ----------------------------------------------------------------------------
  1.6801 +* Name:       CVDecTestEngine::SetFrameDrop()
  1.6802 +* Purpose:
  1.6803 +* Note:
  1.6804 +* Parameters: TInt aFrameInterval, TInt aFrameNum, TBool aFrameDropMarker
  1.6805 +* Return:     None
  1.6806 +* --------------------------------------------------------------------------*/
  1.6807 +
  1.6808 +void CVDecTestEngine::SetFrameDrop(TInt aFrameInterval, TInt aFrameNum, TBool aFrameDropMarker )
  1.6809 +{
  1.6810 +	PRINT(_L("CVDecTestEngine::SetFrameDrop, In"));
  1.6811 +
  1.6812 +
  1.6813 +	iFrameDropInterval = aFrameInterval;
  1.6814 +	iFrameDropNum = aFrameNum;
  1.6815 +	iFrameDropMarker = aFrameDropMarker;
  1.6816 +
  1.6817 +
  1.6818 +	PRINT(_L("CVDecTestEngine::SetFrameDrop, Out"));
  1.6819 +}
  1.6820 +
  1.6821 +/* ----------------------------------------------------------------------------
  1.6822 +* Name:       CVDecTestEngine::SetFLVPassword()
  1.6823 +* Purpose:
  1.6824 +* Note:
  1.6825 +* Parameters: TDesC8& aPassword
  1.6826 +* Return:     None
  1.6827 +* --------------------------------------------------------------------------*/
  1.6828 +void CVDecTestEngine::SetFLVPassword(TDesC8& aPassword)
  1.6829 +{
  1.6830 +	PRINT(_L("CVDecTestEngine::SetFLVPassword, In"));
  1.6831 +
  1.6832 +	_LIT8(KNullTerminate, "\0");
  1.6833 +	iSetPassword = ETrue;
  1.6834 +	iPasswordForFLV.Copy( aPassword);
  1.6835 +	iPasswordForFLV.Append( KNullTerminate );
  1.6836 +	TBuf16<128> passwordPrint;
  1.6837 +	passwordPrint.Copy( iPasswordForFLV );
  1.6838 +
  1.6839 +	PRINT((_L("CVDecTestEngine::SetFLVPassword, iPasswordForFLV [%S]"), &passwordPrint))
  1.6840 +	PRINT(_L("CVDecTestEngine::SetFLVPassword, Out"));
  1.6841 +
  1.6842 +}
  1.6843 +
  1.6844 +/* ----------------------------------------------------------------------------
  1.6845 +* Name:       CVDecTestEngine::EnablingInstantFpsL()
  1.6846 +* Purpose:
  1.6847 +* Note:
  1.6848 +* Parameters: TFileName& aOutFileName
  1.6849 +* Return:     None
  1.6850 +* --------------------------------------------------------------------------*/
  1.6851 +void CVDecTestEngine::EnableInstantFpsL(TFileName& aOutFileName)
  1.6852 +{
  1.6853 +	TInt err = KErrNone;
  1.6854 +	if (!iFrameMeasurement)
  1.6855 +	{
  1.6856 +
  1.6857 +		PRINT((_L("CVDecTestEngine::EnableInstantFpsL(), Frame measurement is not enabled")))
  1.6858 +
  1.6859 +		User::Leave(KErrGeneral);
  1.6860 +	}
  1.6861 +
  1.6862 +	err = iFpsFile.Replace(iFs, aOutFileName, EFileShareExclusive|EFileWrite);
  1.6863 +
  1.6864 +	if ( err  != KErrNone)
  1.6865 +	{
  1.6866 +		PRINT((_L("CVDecTestEngine::EnableInstantFpsL, Output File open Failed")));
  1.6867 +		User::Leave(err);
  1.6868 +	}
  1.6869 +
  1.6870 +	iInstantFpsEnabled = ETrue;
  1.6871 +}
  1.6872 +
  1.6873 +/* ----------------------------------------------------------------------------
  1.6874 +* Name:       CVDecTestEngine::SetSecondScreenAccess
  1.6875 +* Purpose:    Set second screen
  1.6876 +* Note:
  1.6877 +* Parameters: TBool aStatus
  1.6878 +* Return:     None
  1.6879 +* --------------------------------------------------------------------------*/
  1.6880 +void CVDecTestEngine::SetSecondScreenAccess(TBool aStatus)
  1.6881 +{
  1.6882 +	iUseSecondScreen = aStatus;
  1.6883 +}
  1.6884 +//  End	of File