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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __TSU_MMF_SWCODECDEVICES_H__
17 #define __TSU_MMF_SWCODECDEVICES_H__
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>
26 #include <mmf/common/mmfcontroller.h>
27 #include <mmf/common/mmfcontrollerpluginresolver.h>
28 #include <mmf/plugin/mmfplugininterfaceuids.hrh>
30 #include "TSU_MMF_ACOD.h"
32 const TInt PcmToMuLawCompressionTableSize = 256;
33 const TInt MuLawToPcmCompressionTableSize = 256;
34 const TInt PcmToALawCompressionTableSize = 128;
35 const TInt ALawToPcmCompressionTableSize = 256;
38 class CTestSuite_MMF_SwCodecDevices;
41 * @class CTest_MMF_ACOD_U_0001
42 * @test Req. under test REQ172.6.3
44 class CTest_MMF_Gsm610 : public CTestStep_MMF_SwCodecDevices
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);
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 );
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
87 TInt iNumCodedFrames; // number of coded frames in src buffer
92 * CTest_MMF_SwCodecDevices_U_0001
95 class CTest_MMF_SwCodecDevices_U_0001: public CTest_MMF_Gsm610
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);
109 * CTest_MMF_SwCodecDevices_U_0002
112 class CTest_MMF_SwCodecDevices_U_0002: public CTest_MMF_Gsm610
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);
124 * CTest_MMF_SwCodecDevices_U_0003
127 class CTest_MMF_SwCodecDevices_U_0003: public CTest_MMF_Gsm610
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);
138 //[ some utility functions to aid mu and alaw codec tests]
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 );
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
159 CTestMuLawCodec_U_0006();
160 virtual TVerdict DoTestStepL();
161 virtual enum TVerdict DoTestStepPreambleL(void);
162 virtual enum TVerdict DoTestStepPostambleL(void);
164 void ConvertPcmMuLawL(TUint8* aSrcData, TUint8* aCodedData, TInt aNumSamples );
165 void ConvertMuLawPcmL(TUint8* aSrcData, TUint8* aCodedData, TInt aNumSamples );
166 TUint8 LinearToMuLawSample(TInt16 aSample );
168 const static TInt8 MuLawCompressTable[PcmToMuLawCompressionTableSize];
169 const static TInt16 MuLawDecompressTable[MuLawToPcmCompressionTableSize];
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
179 CTestALawCodec_U_0004();
180 virtual TVerdict DoTestStepL();
181 virtual enum TVerdict DoTestStepPreambleL(void);
182 virtual enum TVerdict DoTestStepPostambleL(void);
184 void ConvertPcmALawL(TUint8* aSrcData, TUint8* aCodedData, TInt aNumSamples );
185 void ConvertALawPcmL(TUint8* aSrcData, TUint8* aCodedData, TInt aNumSamples );
186 TUint8 LinearToALawSample(TInt16 aSample);
188 const static TInt8 ALawCompressTable[PcmToALawCompressionTableSize];
189 const static TInt16 ALawDecompressTable[ALawToPcmCompressionTableSize];
192 // This test tests the pcm16 to imaad codec
193 class CTestIMaadCodec: public CTestStep_MMF_SwCodecDevices
197 virtual TVerdict DoTestStepL();
198 virtual enum TVerdict DoTestStepPreambleL(void);
199 virtual enum TVerdict DoTestStepPostambleL(void);
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);
210 //------------------------------------------------------------------
212 #endif// TSU_MMF_SWCODECDEVICES_H__