Update contrib.
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
20 #ifndef __H264DecTestEngine_H
21 #define __H264DecTestEngine_H
27 #include "T_DevVideoConstants.h"
28 #include <Videoplayhwdevice.h>
29 #include <Devvideoplay.h>
30 #include <Devvideobase.h>
32 //#define __CI_HEADERS__
33 //#define __SECUREOUTPUTCI__
37 #include <buffermanagementci.h> // Custom interface buffre management
42 #ifdef __SECUREOUTPUTCI__
43 #include <secureoutputci.h>
46 #include <Bitdev.h> // for display device
47 #include <Fbs.h> // for display device
48 #include <math.h> //pow
50 #ifdef __RESOURCENOTIFICATION__
51 #include <devvideostandardcustominterfaces.h>
67 // FORWARD DECLARATIONS
71 const TUint KMaxNumberOfNals = 100;
72 //const TUint KDataChunkSize = 500000;
82 #define PRINT(x) RDebug::Print x;
121 class CVDecTestEngine;
122 class MVDecEngineObserver;
126 * Video Decoder Test Engine Observer
131 class MVDecEngineObserver
135 virtual void MvdeStreamEndReached() = 0;
136 virtual void MvdeSetError(TInt aError) = 0;
140 * Video Decoder Test Engine
141 * implements common test execution block
145 class CVDecTestEngine : public CBase , public MMMFDevVideoPlayObserver
146 #ifdef __CI_HEADERS__
147 ,public MMmfVideoBufferManagementObserver
149 #ifdef __RESOURCENOTIFICATION__
150 ,public MMmfVideoResourceObserver
159 CVDecTestEngine () { }
161 static CVDecTestEngine* NewL(MVDecEngineObserver& aTestClass);
164 void SetCodecType(TVideoCodec aCodec);
165 //void GetDecoderInfoL(const TDesC8& aMimeType, TBool aExactMatch);
166 //void GetPostProcessorInfoL(TInt aCombination);
167 void GetHeaderInformationL();
169 void GetHeaderInformationL(TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aDataUnitEncapsulation);
170 //void GetHeaderInfoL(const TUid& aDecUid, TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aDataUnitEncapsulation);
171 void GetBitstreamCountersL();
172 void PreDecoderBufferBytes();
173 void PictureBufferBytes();
175 // Video test control methods
176 //void SetUpL(TBool aScreenAcces);
177 void SetUpL(TSize aSize, TBool aScreenAccess, TBool aCIBuffMgmt);
178 void CreateDecoderL(const TUid& aDecUid, TVideoCodec aCodec, const TDesC8& aMimeType, TYuvDataOptions aOutFormat);
179 void CreatePostProcessorL(const TUid& aPostprocUid, const TYuvFormat& aInputFormat, const TUncompressedVideoFormat& aOutputFormat, TUint32 aCombination);
180 void CreateDecPostprocL(const TUid& aDecUid, TVideoCodec aCodec, const TUid& aPostprocUid, TUint32 aCombination);
182 TInt InitializeAndDelete();
183 TInt Start(TBool aInputEnd);
187 void FreezePicture(TTimeIntervalMicroSeconds aTimeStamp);
188 void ReleaseFreeze(TTimeIntervalMicroSeconds aTimeStamp);
190 void SetFrameMatch(TBool aMatch);
191 TInt FrameJump(TInt aNumToJump );
192 void SetFrameDrop(TInt aFrameInterval, TInt aFrameNum, TBool aFrameDropMarker );
193 void SetFLVPassword(TDesC8& aPassword);
194 void EnableInstantFpsL(TFileName& aOutFileName);
196 // Select and set Postprocessing
197 void SetPostProcessTypesL(TInt aHWDevice, TUint32 aCombination);
198 void SetInputCropOptionsL(TInt aHWDevice, TRect aCrop);
199 void SetYuvToRgbOptionsL(TInt aHWDevice, TYuvToRgbOptions aOptions);
200 void SetRotateOptionsL(TInt aHWDevice, TRotationType aRotation);
201 void SetScaleOptionsL(TInt aHWDevice, TSize aSize, TBool aAntiAliasFiltering);
202 void SetScaleOptionsL(TInt aNumFactor,TInt aDenoFactor, TBool aAntiAliasFiltering);
203 void SetOutputCropOptionsL(TInt aHWDevice, TRect aCrop);
207 void SetClockSource();
208 void SetInputBufferSize(TInt aSize);
209 void SetHrdVbvSpec(THrdVbvSpecification aHrdVbvSpec, const TDesC8& aHrdVbvParams);
210 void SetPostProcSpecificOptionsL(TInt aHWDevice, const TDesC8& aOptions);
211 void SetScreenClipRegion(TRegion& aRegion);
212 void SetPauseOnClipFail(TBool aPause);
214 void GetPictureCounters();
215 void NumFreeBuffers();
216 void NumComplexityLevels(TInt aHWDevice);
218 void GetNewPictureInfo(TTimeIntervalMicroSeconds& aEarliestTimestamp,
219 TTimeIntervalMicroSeconds& aLatestTimestamp);
220 void GetTimedSnapshotL(const TUncompressedVideoFormat& aFormat,
221 const TTimeIntervalMicroSeconds& aPresentationTimestamp);
222 void GetTimedSnapshotL(const TUncompressedVideoFormat& aFormat, const TPictureId& aPictureId);
223 void CancelTimedSnapshot();
224 void GetSupportedSnapshotFormatsL();
227 void SetComplexityLevel(TInt aHWDevice, TInt aLevel);
228 void GetComplexityLevelInfo(TInt aHWDevice, TInt aLevel);
231 void StartDirectScreenAccessL();
232 void StartDirectScreenAccessL(TRect aVideoRect, TRect aClipRegion);
233 void AbortDirectScreenAccess();
236 void SetWindowRect(TInt aX, TInt aY, TSize aSize);
237 void SetSecondScreenAccess(TBool aStatus);
240 void GetSnapshotL(TUncompressedVideoFormat& aFormat);
242 void EnableSynchronization(TInt aFrameRate);
243 void EnableFrameMeasurementTest(TBool aEnable);
244 void SetSecureOutputL(TBool aSecure);
245 void SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition);
246 void ResetPosition();
247 TTimeIntervalMicroSeconds PlaybackPosition();
248 void DecodingPosition();
249 void ListFrameSizeL(RArray<TInt> aFramesizes);
250 TInt GetFrameSizeCount();
251 //void GetPictureCounter();
252 void SetLandscapeMode();
253 void SelectDecoderL(const TUid& aUid);
254 void SelectPostProcessorL(const TUid& aUid);
255 void SetInputFormatL(TInt aHwDev, const TUncompressedVideoFormat& aFormat);
256 void SetInputFormatL(TInt aHwDev, const CCompressedVideoFormat& aFormat,
257 TVideoDataUnitType aDataUnitType, TVideoDataUnitEncapsulation aEncapsulation,
259 void SetOutputFormatL(TInt aHwDev, const TUncompressedVideoFormat& aFormat);
260 void SetBufferOptionsL(const CMMFDevVideoPlay::TBufferOptions& aOptions);
261 void GetBufferOptions();
262 void SynchronizeDecoding(TBool aSynch);
263 void SetVideoDestScreenL(TBool aDest);
264 void SetYuvToRgbOptionsL(TInt aHWDevice, const TYuvToRgbOptions& aOptions, const TYuvFormat& aYuvFormat, TRgbFormat aRgbFormat);
265 void FindCommonFormatsL();
266 TInt FindDecodersL(const TDesC8& aMimeType, TUint32 aPostProcType, TBool aExactMatch, TUid& aUid);
267 TInt FindPostProcessorsL(TUid& aUid, TUint32 aPostProcType);
268 void GetDecoderListL();
269 void ConfigureDecoderL(TVideoPictureHeader& aVideoPictureHeader);
270 void ConfigureDecoderL();
271 void GetOutputFormatListL(TInt aHWDevice);
272 void GetPostProcessorListL();
273 void VideoDecoderInfoL(TUid aVideoDecoder);
274 void PostProcessorInfoL(TUid aPostProcessor);
276 TReal ConvertToRealL(const TDesC& aPtr);
279 void OpenFileL(TFileName& aInFileName);
280 void OpenFileL(TFileName& aOutFileName, TFileName& aInFileName);
282 void CorruptInput(TInt aFilter, TInt aInterval, TInt aFrameNum, TInt aPct);
283 void CorruptEngineL();
284 void CorruptEngineL( TVideoInputBuffer* aCodedInBuffer );
285 TInt CreateCorruptedFileL();
286 void OpenFileToWriteL(TFileName& aInFileName);
287 TInt ReadVC1FrameL(TVideoInputBuffer* aCodedInBuffer);
288 TInt ReadMPEG4FrameL(TVideoInputBuffer* aCodedInBuffer);
290 TInt SupportsFormatL(const TUid& aUid, const CCompressedVideoFormat& aFormat);
291 TInt SupportsFormatInfoL(const TUid& aUid, const CCompressedVideoFormat& aFormat);
292 TInt SupportsAccelerationL(TInt aHwDev, const TUid& aUid);
293 TInt SupportsDirectDisplayL(TInt aHwDev, const TUid& aUid);
294 TInt SupportsMaxBitrateL(const TUid& aUid, TInt aBitrate);
295 TInt SupportsMaxPictureSizeL(const TUid& aUid, TSize aSize);
296 TInt SupportsMaxPictureRateL(const TUid& aUid, TPictureRateAndSize& aRateAndSize);
297 TInt SupportsPictureLossL(const TUid& aUid);
298 TInt SupportsSliceLossL(const TUid& aUid);
299 TInt SupportsOutputFormatL(TInt aHwdev, const TUncompressedVideoFormat& aFormat);
300 void SetSlowClient(TBool aOption);
301 void SetFastClient(TBool aOption);
303 TInt MoveFileL(const TDesC &anOld, const TDesC &aNew);
304 TInt CopyFileL(const TDesC &anOld, const TDesC &aNew);
307 // For Active objects
308 void HandleNewBufferL();
310 // From DevVideo Play observer
311 void MdvpoNewBuffers();
312 void MdvpoReturnPicture(TVideoPicture* aPicture);
313 void MdvpoSupplementalInformation(const TDesC8& aData, const TTimeIntervalMicroSeconds& aTimestamp, const TPictureId& aPictureId);
314 void MdvpoPictureLoss();
315 void MdvpoPictureLoss(const TArray<TPictureId>& aPictures);
316 void MdvpoSliceLoss(TUint aFirstMacroblock, TUint aNumMacroblocks, const TPictureId& aPicture);
317 void MdvpoReferencePictureSelection(const TDesC8& aSelectionData);
318 void MdvpoTimedSnapshotComplete(TInt aError, TPictureData* aPictureData, const TTimeIntervalMicroSeconds& aPresentationTimestamp, const TPictureId& aPictureId);
319 void MdvpoNewPictures();
320 void MdvpoFatalError(TInt aError);
321 void MdvpoInitComplete(TInt aError);
322 void MdvpoStreamEnd();
324 // Buffer Management Custom Interface observer
325 #ifdef __CI_HEADERS__
326 void MmvbmoNewBuffers();
327 void MmvbmoReleaseBuffers();
329 #ifdef __RESOURCENOTIFICATION__
330 void MmvroResourcesLost(TUid aMediaDevice);
331 void MmvroResourcesRestored(TUid aMediaDevice);
335 // Own test functions
336 void GetInputBufferL();
337 void FillAndSendBufferL();
338 void GetReturnedPictureL();
339 void SaveAndReturnPicture();
340 TInt ReadOneCodedPicture(TVideoInputBuffer* aCodedInBuffer);
341 TInt ReadOneCodedPicture(TVideoInputBuffer* aCodedInBuffer, TInt aSize);
342 TInt ReadRawPicture();
345 TUint8 ReadByteFromFile();
346 void GoBackInFile(TUint aBytes);
347 void ReadDataToBuffer(TVideoInputBuffer* aCodedInBuffer, TInt aSize, TBool aDiscard = EFalse);
348 TBool CheckAndFillDataChunk();
349 TBool ReadItemLE(unsigned char *readBuffer, int Size, unsigned char* pItem);
350 TInt LoadNextFrameL(TVideoInputBuffer* aCodedInBuffer);
351 void ConstructL(MVDecEngineObserver& aTestClass);
352 void AssertTIntEqualL(TInt aExpected, TInt aActual);
353 void PrintUncompressedFormat(const TUncompressedVideoFormat& aFormat);
356 CMMFDevVideoPlay* iDevvp; //points to DevVideo Play
357 THwDeviceId iDecHWDevId; //Hwdevise ID of selected Decoder
358 THwDeviceId iPostProcId; //Hwdevise ID of selected postprocessor
359 TUid iPostProcessorUid;
361 CVDecTestAO* iDecTestAO;
362 TBool iRunning; //State of scheduler
363 TYuvFormat iRawFormat; //Used for Decoder output, postprocessor input
364 TRgbFormat iDispFormat; // Display Options
367 TVideoInputBuffer* iCodedInBuffer; // Pointer to Decoder input buffer
368 TVideoInputBuffer* iCorruptedInBuffer; //Pointer to corrupted input for decoder
369 TInt iInBuffSize; // Size of decoder input buffer
370 TVideoPicture* iOutBuffer; // Pointer to picuture class for output data in memory buffer output
371 TVideoPicture* iOutBufferTemp; // Pointer to picuture class for output data in memory buffer output
372 TVideoPicture* iRawInBuffer; // Used for postprocessor input
373 HBufC8* iRawDataArea; // Pointer to Heap buffer, filled with input data to postprocessor
375 TInt64 iFrameTimeInterval;
376 TInt iSentBuffCount; //Number of frames sent to target HwDevice
377 TInt iReturnedBuffCount; //Number of frames returned from target HwDevice
378 TInt iPictureLoss; // number of picture loss
381 TVideoCodec iCodecType;
383 CSystemClockSource* iClock; //Clock source, based on System clock
385 TBool iDirectScreenAccess;
387 TBool iDisableInputEnd;
388 TBool iFrameMatch; // input frame number should match output frame number
390 TInt iFrameJumpCounter;
391 TInt iFrameWriteLength;
392 TInt iCurrentFilePos;
393 #ifdef __CI_HEADERS__
394 MMmfVideoBufferManagement* iCIBuffMgmt;
396 MVDecEngineObserver* iTestClass;
397 TBool iFrameMeasurement;
399 TBool iLandscapeMode;
400 TInt iNoBuffAvailable;
401 RArray<TInt> iFrameSizeList;
402 TPictureData iPictureDataSnapshot;
403 TBuf8<128> iInFileName;
404 TBool iSetSlowClient;
405 TBool iSetFastClient;
409 TUint32* iNalOffsetArray;
410 TUint32* iNalLengthArray;
414 TUint8* iReadDataChunk;
415 TUint8* iWriteDataChunk;
416 TUint iDataReadFromFile;
417 TUint iDataThreshold;
420 TBool iUseSecondScreen;
424 RFile iInFile; // Input data file
425 RFile iOutFile; // Output data file
426 RFile iOutCorruptedFile;
428 TBool iDeleteDecoderFromInitComp;
431 TBool iCorruptMarker;
437 TInt iCorruptCounter;
438 TInt iFrameDropCounter;
439 TInt iFrameDropInterval;
441 TInt iFrameDropNumCounter;
442 TBool iFrameDropMarker;
443 TFileName iOutFileName;
444 TFileName iOutCorruptedFileName;
445 TBool iOutCorruptedFileOpen;
446 TBuf8<128> iPasswordForFLV;
448 TBool iInstantFpsEnabled;
449 RArray<TTimeIntervalMicroSeconds> iInstantFpsList;
458 TInt32 iDataChunkSize;
461 CFbsScreenDevice* iScreenDevice;
463 CActiveSchedulerWait* iScheduler; //Nested scheduler
466 TDateTime iTimeBeforeDecoding;
467 TDateTime iTimeAfterDecoding;
468 //TInt iNumFramesDecoded;
469 //TUint64 iTotalTime;
470 //TBool iIsBeforeTimeUsed;
471 TUint64 iBeforeDecodingTime;
472 RArray<TUint64> iBeforeDecoingTimesQueue;
476 TBool iNumFreeBufsFirstTime;
477 TTimeIntervalMicroSeconds iTimeToPlay;
478 TTimeIntervalMicroSeconds iPresentationTimestamp;
479 TBool iNoOfFreeBuffFlag;
484 TFLVFileType iFLVFileType;
491 * Video Decoder Test Engine AO
492 * Provides async services
497 class CVDecTestAO : public CActive
500 CVDecTestAO(CVDecTestEngine* aTestEngine);
508 CVDecTestEngine* iTestEngine;