os/mm/mmlibs/mmfw/tsrc/mmfunittest/SwCodecDevices/TSU_MMF_SWCODECDEVICES.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/SwCodecDevices/TSU_MMF_SWCODECDEVICES.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,213 @@
     1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef __TSU_MMF_SWCODECDEVICES_H__
    1.20 +#define __TSU_MMF_SWCODECDEVICES_H__
    1.21 +
    1.22 +#include <testframework.h>
    1.23 +#include <mmf/server/mmfcodec.h>
    1.24 +#include <mmf/server/mmfbuffer.h>
    1.25 +#include <mmf/server/mmfdatabuffer.h>
    1.26 +#include <mmf/common/mmfutilities.h>
    1.27 +#include <mmf/common/mmffourcc.h>
    1.28 +
    1.29 +#include <mmf/common/mmfcontroller.h>
    1.30 +#include <mmf/common/mmfcontrollerpluginresolver.h>
    1.31 +#include <mmf/plugin/mmfplugininterfaceuids.hrh>
    1.32 +
    1.33 +#include "TSU_MMF_ACOD.h"
    1.34 +
    1.35 +const TInt PcmToMuLawCompressionTableSize = 256;
    1.36 +const TInt MuLawToPcmCompressionTableSize = 256;
    1.37 +const TInt PcmToALawCompressionTableSize = 128;
    1.38 +const TInt ALawToPcmCompressionTableSize = 256;
    1.39 +
    1.40 +class CTestSuite ;
    1.41 +class CTestSuite_MMF_SwCodecDevices;
    1.42 +
    1.43 +/** 
    1.44 + * @class CTest_MMF_ACOD_U_0001
    1.45 + * @test Req. under test REQ172.6.3 
    1.46 + */
    1.47 +class CTest_MMF_Gsm610 : public CTestStep_MMF_SwCodecDevices
    1.48 +	{
    1.49 +public:
    1.50 +	CTest_MMF_Gsm610();
    1.51 +	~CTest_MMF_Gsm610();
    1.52 +protected:
    1.53 +	void ReadDataL(CMMFDataBuffer*& aBuffer, const TDesC& aFile1);
    1.54 +	void PrintGsm610Frame(TUint8* aGsm610Frame);
    1.55 +	void PrintPcmDataFrame(TUint8* aPcm16Frame);
    1.56 +	TBool CompareEncodeResults( CMMFDataBuffer* aEncoded, CMMFDataBuffer* aRefFrame );
    1.57 +	TBool CompareDecodeResults(CMMFDataBuffer* aEncoded, CMMFDataBuffer* aRefFrame );
    1.58 +	TBool CompareGsm610Frames( TUint8* aGsmFrame,TUint8* aRefGsmFrame );
    1.59 +	void UnpackFrame1(struct codes* aCodeBuf, TUint8* pbuf);
    1.60 +	void UnpackFrame0(struct codes* aCodeBuf, TUint8* pbuf);
    1.61 +	void PackFrame0(struct codes* aCodeBuf, TInt8* pbuf);
    1.62 +	void PackFrame1(struct codes* aCodeBuf, TInt8* pbuf);
    1.63 +   
    1.64 +	TBool Compare( codes& aFrame1, codes& aFrame2 );
    1.65 +	void LogGsmFrames( codes& aGsmFrame, codes& aRefGsmFrame );
    1.66 +	void LogGsmFrame ( codes& aFrame );
    1.67 +	void FillPcmBuffer( CMMFDataBuffer& aSrcBuffer );
    1.68 +	void OpenFileL( RFile& aFile, const TDesC& aFileName );
    1.69 +	void ReadDataBufferL( const RFile& aFile, CMMFDataBuffer& aBuffer );
    1.70 +	void CloseFileL( RFile& aFile );
    1.71 +	void ParseFrameL( struct codes& aFrame, TUint8* &aBuffer );
    1.72 +	void ParseCodedDataL( CMMFDataBuffer* aBuffer );
    1.73 +protected:
    1.74 +	//[ files for conformance testing of the codec 
    1.75 +	// which are defined in the ETSI standard ]
    1.76 +	TPtrC iSourceDataFile;  // source data file name
    1.77 +	TPtrC iCodedDataFile;   // coded data file name
    1.78 +	TPtrC iDecodedDataFile; // decoded data file name
    1.79 +	RFile iSrcFile;         // src file 
    1.80 +	RFile iCodedFile;       // coded file
    1.81 +	RFile iDecodeFile;      // decoded file
    1.82 +	CMMFDataBuffer* iRefSrcData;    // reference source data
    1.83 +	CMMFDataBuffer* iRefCodedData; // refernce decoded data
    1.84 +	CMMFDataBuffer* iRefDecodedData; // refernce decoded data
    1.85 +	CMMFDataBuffer* iCodedData;   // buffer of coded data
    1.86 +	CMMFDataBuffer* iDecodedData; // buffer of actual decoded data
    1.87 +	CMMFDataBuffer* iScratchData; // buffer of actual decoded data
    1.88 +	RFs iFs;                      // file server
    1.89 +	RFile iFile;
    1.90 +	TInt iNumCodedFrames;         // number of coded frames in src buffer
    1.91 +	} ;
    1.92 +
    1.93 +/*
    1.94 +*
    1.95 +* CTest_MMF_SwCodecDevices_U_0001
    1.96 +*
    1.97 +**/
    1.98 +class CTest_MMF_SwCodecDevices_U_0001: public CTest_MMF_Gsm610
    1.99 +{
   1.100 +
   1.101 +public:
   1.102 +	CTest_MMF_SwCodecDevices_U_0001();
   1.103 +	~CTest_MMF_SwCodecDevices_U_0001();
   1.104 +	virtual TVerdict DoTestStepL();
   1.105 +	virtual enum TVerdict DoTestStepPreambleL(void);
   1.106 +	virtual enum TVerdict DoTestStepPostambleL(void);
   1.107 +};
   1.108 +
   1.109 +
   1.110 +/**
   1.111 +*
   1.112 +* CTest_MMF_SwCodecDevices_U_0002
   1.113 +*
   1.114 +**/
   1.115 +class CTest_MMF_SwCodecDevices_U_0002: public CTest_MMF_Gsm610
   1.116 +{
   1.117 +public:
   1.118 +	CTest_MMF_SwCodecDevices_U_0002();
   1.119 +	~CTest_MMF_SwCodecDevices_U_0002();
   1.120 +	virtual TVerdict DoTestStepL();
   1.121 +	virtual enum TVerdict DoTestStepPreambleL(void);
   1.122 +	virtual enum TVerdict DoTestStepPostambleL(void);
   1.123 +};
   1.124 +
   1.125 +/**
   1.126 +*
   1.127 +* CTest_MMF_SwCodecDevices_U_0003
   1.128 +*
   1.129 +**/
   1.130 +class CTest_MMF_SwCodecDevices_U_0003: public CTest_MMF_Gsm610
   1.131 +{
   1.132 +public:
   1.133 +	CTest_MMF_SwCodecDevices_U_0003();
   1.134 +	~CTest_MMF_SwCodecDevices_U_0003();
   1.135 +	virtual TVerdict DoTestStepL();
   1.136 +	virtual enum TVerdict DoTestStepPreambleL(void);
   1.137 +	virtual enum TVerdict DoTestStepPostambleL(void);
   1.138 +
   1.139 +};
   1.140 +
   1.141 +//[ some utility functions to aid mu and alaw codec tests]
   1.142 +class TLawUtility
   1.143 +	{
   1.144 +	public:
   1.145 +      void FillSrcBufferL( TUint8* aSrcData, TInt aNoSamples, TInt16 aOffset );
   1.146 +	  TBool CompareCodedDataL(TUint8* aCodedData,TUint8* aRefCodedData, TInt aNoSamples );
   1.147 +	  TReal SNRatioL(TUint8* aDecodedData, TUint8* aSrcData, TInt aNoSamples );
   1.148 +	  TBool CompareSNRatiosL( TReal aCodecSN, TReal aCodecSN2, TReal aTolerance );
   1.149 +	  TInt16 AssembleValL(TUint8* aDecodedData);
   1.150 +	  TReal ComputeSNL( TReal aSumSigSquared, TReal aSumErrorSquared );
   1.151 +	  TReal SumSquaredL( TUint8* aData, TInt aNoSamples );
   1.152 +	  TReal SumErrorSquaredL( TUint8* aData, TUint8* aData2, TInt aNoSamples );
   1.153 +	};
   1.154 +
   1.155 +//[ This Test compares the Symbian implmentation
   1.156 +// against another reference implementation
   1.157 +// of the mu law conversion codec due to problems encountered with
   1.158 +// gold wave coding which was different ]
   1.159 +class CTestMuLawCodec_U_0006: public CTestStep_MMF_SwCodecDevices
   1.160 +{
   1.161 +public:
   1.162 +	CTestMuLawCodec_U_0006();
   1.163 +	virtual TVerdict DoTestStepL();
   1.164 +	virtual enum TVerdict DoTestStepPreambleL(void);
   1.165 +	virtual enum TVerdict DoTestStepPostambleL(void);
   1.166 +private:
   1.167 +	void ConvertPcmMuLawL(TUint8* aSrcData, TUint8* aCodedData, TInt aNumSamples );
   1.168 +    void ConvertMuLawPcmL(TUint8* aSrcData, TUint8* aCodedData, TInt aNumSamples );
   1.169 +	TUint8 LinearToMuLawSample(TInt16 aSample );
   1.170 +private:
   1.171 +	const static TInt8 MuLawCompressTable[PcmToMuLawCompressionTableSize];
   1.172 +	const static TInt16 MuLawDecompressTable[MuLawToPcmCompressionTableSize];
   1.173 +};
   1.174 +
   1.175 +//[ This Test compares the Symbian implmentation
   1.176 +// against another reference implementation
   1.177 +// of the mu law conversion codec due to problems encountered with
   1.178 +// gold wave coding which was different ]
   1.179 +class CTestALawCodec_U_0004: public CTestStep_MMF_SwCodecDevices
   1.180 +{
   1.181 +public:
   1.182 +	CTestALawCodec_U_0004();
   1.183 +	virtual TVerdict DoTestStepL();
   1.184 +	virtual enum TVerdict DoTestStepPreambleL(void);
   1.185 +	virtual enum TVerdict DoTestStepPostambleL(void);
   1.186 +private:
   1.187 +    void ConvertPcmALawL(TUint8* aSrcData, TUint8* aCodedData, TInt aNumSamples );
   1.188 +    void ConvertALawPcmL(TUint8* aSrcData, TUint8* aCodedData, TInt aNumSamples );
   1.189 +	TUint8 LinearToALawSample(TInt16 aSample);
   1.190 +private:
   1.191 +	const static TInt8  ALawCompressTable[PcmToALawCompressionTableSize];
   1.192 +	const static TInt16 ALawDecompressTable[ALawToPcmCompressionTableSize];
   1.193 +};
   1.194 +
   1.195 +// This test tests the pcm16 to imaad codec
   1.196 +class CTestIMaadCodec: public CTestStep_MMF_SwCodecDevices
   1.197 +{
   1.198 +public:
   1.199 +	CTestIMaadCodec();
   1.200 +	virtual TVerdict DoTestStepL();
   1.201 +	virtual enum TVerdict DoTestStepPreambleL(void);
   1.202 +	virtual enum TVerdict DoTestStepPostambleL(void);
   1.203 +private:
   1.204 +	// fill src buffer with linear ramp
   1.205 +	// for coding purposes
   1.206 +		void  FillSrcBufferL( CMMFDescriptorBuffer& aBuffer );
   1.207 +		TBool CompareResults( TReal aExpectedSNRatioDb, 
   1.208 +			                  CMMFDescriptorBuffer* aSrcBuffer,     
   1.209 +		                      CMMFDescriptorBuffer* aSinkBuffer);
   1.210 +};
   1.211 +
   1.212 +
   1.213 +//------------------------------------------------------------------ 
   1.214 +
   1.215 +#endif// TSU_MMF_SWCODECDEVICES_H__
   1.216 +