os/mm/mmlibs/mmfw/tsrc/mmfunittest/SwCodecDevices/TSU_MMF_SWCODECDEVICES.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __TSU_MMF_SWCODECDEVICES_H__
    17 #define __TSU_MMF_SWCODECDEVICES_H__
    18 
    19 #include <testframework.h>
    20 #include <mmf/server/mmfcodec.h>
    21 #include <mmf/server/mmfbuffer.h>
    22 #include <mmf/server/mmfdatabuffer.h>
    23 #include <mmf/common/mmfutilities.h>
    24 #include <mmf/common/mmffourcc.h>
    25 
    26 #include <mmf/common/mmfcontroller.h>
    27 #include <mmf/common/mmfcontrollerpluginresolver.h>
    28 #include <mmf/plugin/mmfplugininterfaceuids.hrh>
    29 
    30 #include "TSU_MMF_ACOD.h"
    31 
    32 const TInt PcmToMuLawCompressionTableSize = 256;
    33 const TInt MuLawToPcmCompressionTableSize = 256;
    34 const TInt PcmToALawCompressionTableSize = 128;
    35 const TInt ALawToPcmCompressionTableSize = 256;
    36 
    37 class CTestSuite ;
    38 class CTestSuite_MMF_SwCodecDevices;
    39 
    40 /** 
    41  * @class CTest_MMF_ACOD_U_0001
    42  * @test Req. under test REQ172.6.3 
    43  */
    44 class CTest_MMF_Gsm610 : public CTestStep_MMF_SwCodecDevices
    45 	{
    46 public:
    47 	CTest_MMF_Gsm610();
    48 	~CTest_MMF_Gsm610();
    49 protected:
    50 	void ReadDataL(CMMFDataBuffer*& aBuffer, const TDesC& aFile1);
    51 	void PrintGsm610Frame(TUint8* aGsm610Frame);
    52 	void PrintPcmDataFrame(TUint8* aPcm16Frame);
    53 	TBool CompareEncodeResults( CMMFDataBuffer* aEncoded, CMMFDataBuffer* aRefFrame );
    54 	TBool CompareDecodeResults(CMMFDataBuffer* aEncoded, CMMFDataBuffer* aRefFrame );
    55 	TBool CompareGsm610Frames( TUint8* aGsmFrame,TUint8* aRefGsmFrame );
    56 	void UnpackFrame1(struct codes* aCodeBuf, TUint8* pbuf);
    57 	void UnpackFrame0(struct codes* aCodeBuf, TUint8* pbuf);
    58 	void PackFrame0(struct codes* aCodeBuf, TInt8* pbuf);
    59 	void PackFrame1(struct codes* aCodeBuf, TInt8* pbuf);
    60    
    61 	TBool Compare( codes& aFrame1, codes& aFrame2 );
    62 	void LogGsmFrames( codes& aGsmFrame, codes& aRefGsmFrame );
    63 	void LogGsmFrame ( codes& aFrame );
    64 	void FillPcmBuffer( CMMFDataBuffer& aSrcBuffer );
    65 	void OpenFileL( RFile& aFile, const TDesC& aFileName );
    66 	void ReadDataBufferL( const RFile& aFile, CMMFDataBuffer& aBuffer );
    67 	void CloseFileL( RFile& aFile );
    68 	void ParseFrameL( struct codes& aFrame, TUint8* &aBuffer );
    69 	void ParseCodedDataL( CMMFDataBuffer* aBuffer );
    70 protected:
    71 	//[ files for conformance testing of the codec 
    72 	// which are defined in the ETSI standard ]
    73 	TPtrC iSourceDataFile;  // source data file name
    74 	TPtrC iCodedDataFile;   // coded data file name
    75 	TPtrC iDecodedDataFile; // decoded data file name
    76 	RFile iSrcFile;         // src file 
    77 	RFile iCodedFile;       // coded file
    78 	RFile iDecodeFile;      // decoded file
    79 	CMMFDataBuffer* iRefSrcData;    // reference source data
    80 	CMMFDataBuffer* iRefCodedData; // refernce decoded data
    81 	CMMFDataBuffer* iRefDecodedData; // refernce decoded data
    82 	CMMFDataBuffer* iCodedData;   // buffer of coded data
    83 	CMMFDataBuffer* iDecodedData; // buffer of actual decoded data
    84 	CMMFDataBuffer* iScratchData; // buffer of actual decoded data
    85 	RFs iFs;                      // file server
    86 	RFile iFile;
    87 	TInt iNumCodedFrames;         // number of coded frames in src buffer
    88 	} ;
    89 
    90 /*
    91 *
    92 * CTest_MMF_SwCodecDevices_U_0001
    93 *
    94 **/
    95 class CTest_MMF_SwCodecDevices_U_0001: public CTest_MMF_Gsm610
    96 {
    97 
    98 public:
    99 	CTest_MMF_SwCodecDevices_U_0001();
   100 	~CTest_MMF_SwCodecDevices_U_0001();
   101 	virtual TVerdict DoTestStepL();
   102 	virtual enum TVerdict DoTestStepPreambleL(void);
   103 	virtual enum TVerdict DoTestStepPostambleL(void);
   104 };
   105 
   106 
   107 /**
   108 *
   109 * CTest_MMF_SwCodecDevices_U_0002
   110 *
   111 **/
   112 class CTest_MMF_SwCodecDevices_U_0002: public CTest_MMF_Gsm610
   113 {
   114 public:
   115 	CTest_MMF_SwCodecDevices_U_0002();
   116 	~CTest_MMF_SwCodecDevices_U_0002();
   117 	virtual TVerdict DoTestStepL();
   118 	virtual enum TVerdict DoTestStepPreambleL(void);
   119 	virtual enum TVerdict DoTestStepPostambleL(void);
   120 };
   121 
   122 /**
   123 *
   124 * CTest_MMF_SwCodecDevices_U_0003
   125 *
   126 **/
   127 class CTest_MMF_SwCodecDevices_U_0003: public CTest_MMF_Gsm610
   128 {
   129 public:
   130 	CTest_MMF_SwCodecDevices_U_0003();
   131 	~CTest_MMF_SwCodecDevices_U_0003();
   132 	virtual TVerdict DoTestStepL();
   133 	virtual enum TVerdict DoTestStepPreambleL(void);
   134 	virtual enum TVerdict DoTestStepPostambleL(void);
   135 
   136 };
   137 
   138 //[ some utility functions to aid mu and alaw codec tests]
   139 class TLawUtility
   140 	{
   141 	public:
   142       void FillSrcBufferL( TUint8* aSrcData, TInt aNoSamples, TInt16 aOffset );
   143 	  TBool CompareCodedDataL(TUint8* aCodedData,TUint8* aRefCodedData, TInt aNoSamples );
   144 	  TReal SNRatioL(TUint8* aDecodedData, TUint8* aSrcData, TInt aNoSamples );
   145 	  TBool CompareSNRatiosL( TReal aCodecSN, TReal aCodecSN2, TReal aTolerance );
   146 	  TInt16 AssembleValL(TUint8* aDecodedData);
   147 	  TReal ComputeSNL( TReal aSumSigSquared, TReal aSumErrorSquared );
   148 	  TReal SumSquaredL( TUint8* aData, TInt aNoSamples );
   149 	  TReal SumErrorSquaredL( TUint8* aData, TUint8* aData2, TInt aNoSamples );
   150 	};
   151 
   152 //[ This Test compares the Symbian implmentation
   153 // against another reference implementation
   154 // of the mu law conversion codec due to problems encountered with
   155 // gold wave coding which was different ]
   156 class CTestMuLawCodec_U_0006: public CTestStep_MMF_SwCodecDevices
   157 {
   158 public:
   159 	CTestMuLawCodec_U_0006();
   160 	virtual TVerdict DoTestStepL();
   161 	virtual enum TVerdict DoTestStepPreambleL(void);
   162 	virtual enum TVerdict DoTestStepPostambleL(void);
   163 private:
   164 	void ConvertPcmMuLawL(TUint8* aSrcData, TUint8* aCodedData, TInt aNumSamples );
   165     void ConvertMuLawPcmL(TUint8* aSrcData, TUint8* aCodedData, TInt aNumSamples );
   166 	TUint8 LinearToMuLawSample(TInt16 aSample );
   167 private:
   168 	const static TInt8 MuLawCompressTable[PcmToMuLawCompressionTableSize];
   169 	const static TInt16 MuLawDecompressTable[MuLawToPcmCompressionTableSize];
   170 };
   171 
   172 //[ This Test compares the Symbian implmentation
   173 // against another reference implementation
   174 // of the mu law conversion codec due to problems encountered with
   175 // gold wave coding which was different ]
   176 class CTestALawCodec_U_0004: public CTestStep_MMF_SwCodecDevices
   177 {
   178 public:
   179 	CTestALawCodec_U_0004();
   180 	virtual TVerdict DoTestStepL();
   181 	virtual enum TVerdict DoTestStepPreambleL(void);
   182 	virtual enum TVerdict DoTestStepPostambleL(void);
   183 private:
   184     void ConvertPcmALawL(TUint8* aSrcData, TUint8* aCodedData, TInt aNumSamples );
   185     void ConvertALawPcmL(TUint8* aSrcData, TUint8* aCodedData, TInt aNumSamples );
   186 	TUint8 LinearToALawSample(TInt16 aSample);
   187 private:
   188 	const static TInt8  ALawCompressTable[PcmToALawCompressionTableSize];
   189 	const static TInt16 ALawDecompressTable[ALawToPcmCompressionTableSize];
   190 };
   191 
   192 // This test tests the pcm16 to imaad codec
   193 class CTestIMaadCodec: public CTestStep_MMF_SwCodecDevices
   194 {
   195 public:
   196 	CTestIMaadCodec();
   197 	virtual TVerdict DoTestStepL();
   198 	virtual enum TVerdict DoTestStepPreambleL(void);
   199 	virtual enum TVerdict DoTestStepPostambleL(void);
   200 private:
   201 	// fill src buffer with linear ramp
   202 	// for coding purposes
   203 		void  FillSrcBufferL( CMMFDescriptorBuffer& aBuffer );
   204 		TBool CompareResults( TReal aExpectedSNRatioDb, 
   205 			                  CMMFDescriptorBuffer* aSrcBuffer,     
   206 		                      CMMFDescriptorBuffer* aSinkBuffer);
   207 };
   208 
   209 
   210 //------------------------------------------------------------------ 
   211 
   212 #endif// TSU_MMF_SWCODECDEVICES_H__
   213