os/mm/mmlibs/mmfw/tsrc/mmfunittest/SwCodecDevices/TSU_MMF_SignConversionCodecs.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// TSU_MMF_CodecTests.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
// EPOC includes
sl@0
    19
#include <e32base.h>
sl@0
    20
#include <e32math.h>
sl@0
    21
#include <f32file.h>
sl@0
    22
#include <s32file.h>
sl@0
    23
sl@0
    24
// Test system includes
sl@0
    25
#include "TSU_MMF_DeviceSuite.h"
sl@0
    26
#include "TSU_MMF_SignConversionCodecs.h"
sl@0
    27
sl@0
    28
//[ codec includes ]
sl@0
    29
#include <mmf/plugin/mmfhwdeviceimplementationuids.hrh>
sl@0
    30
#include "MmfPcm16toAlawhwDevice.h"
sl@0
    31
#include "MmfALawToPcm16HwDevice.h"
sl@0
    32
#include "mmfpcm16toMulawhwdevice.h"
sl@0
    33
#include "MmfMuLawToPcm16hwDevice.h"
sl@0
    34
#include "mmfpcmS8ToPcmS16HwDevice.h"
sl@0
    35
#include "mmfpcmS16PcmS8HwDevice.h"
sl@0
    36
#include "mmfpcm16topcmU16BEHwDevice.h"
sl@0
    37
#include "mmfpcm16SwapEndianhwdevice.h"
sl@0
    38
#include "mmfpcm16ToImaAdpcm.h"
sl@0
    39
#include "MmfImaAdpcmtopcm16hwdevice.h"
sl@0
    40
#include "MMFpcm16ToPcm16HwDevice.h"
sl@0
    41
#include "MMFpcm16ToPcmU8HwDevice.h"
sl@0
    42
#include "MMFpcmU8ToPcm16HwDevice.h"
sl@0
    43
#include "mmfpcmS16PcmS8HwDevice.h"
sl@0
    44
sl@0
    45
sl@0
    46
//[ Codec Unit tests  structure 
sl@0
    47
// The unit tests shall use text files
sl@0
    48
// for small portions of test data 
sl@0
    49
// which should be stored are stored in a simple format
sl@0
    50
// containing the relevant parameters for the test
sl@0
    51
//]
sl@0
    52
class TSignConversionTestParams
sl@0
    53
	{	
sl@0
    54
public:
sl@0
    55
	const TText* iTestName;       // name of the test
sl@0
    56
	};
sl@0
    57
sl@0
    58
// constant table of parameters for tests
sl@0
    59
const TSignConversionTestParams KSignConversionParameters[] =
sl@0
    60
	{	
sl@0
    61
		{_S("MM-MMF-SWCODECDEVICES-U-0017-HP")},
sl@0
    62
		{_S("MM-MMF-SWCODECDEVICES-U-0018-HP")},
sl@0
    63
		{_S("MM-MMF-SWCODECDEVICES-U-0019-HP")},
sl@0
    64
		{_S("MM-MMF-SWCODECDEVICES-U-0020-HP")}, 
sl@0
    65
		{_S("MM-MMF-SWCODECDEVICES-U-0021-HP")}
sl@0
    66
	};
sl@0
    67
sl@0
    68
/**
sl@0
    69
*
sl@0
    70
* PrintComparisonDataL
sl@0
    71
* @param aCodedData the coded data buffer
sl@0
    72
* @param aRefCodedData the reference coded data buffer
sl@0
    73
* 
sl@0
    74
*/
sl@0
    75
void CMMFDataGenerator::PrintComparisonDataL( CMMFDataBuffer& aCodedData, CMMFDataBuffer& aRefCodedData )
sl@0
    76
	{
sl@0
    77
	//[precondition reference coded data is equal in size or longer than coded data ]
sl@0
    78
	if( aRefCodedData.Data().Length() < aCodedData.Data().Length() )
sl@0
    79
		{
sl@0
    80
         //[coded data is longer than reference data]
sl@0
    81
	//	RDebug::Print(_L("Coded Data is longer than refernce data")); Commented under DEF105143
sl@0
    82
		User::Leave( KErrCorrupt );	 
sl@0
    83
		}
sl@0
    84
sl@0
    85
	TUint8* ptr1 = CONST_CAST(TUint8*, aCodedData.Data().Ptr());
sl@0
    86
	TUint8* ptr2 = CONST_CAST(TUint8*, aRefCodedData.Data().Ptr());
sl@0
    87
    TInt length = aCodedData.Data().Length();
sl@0
    88
	//[ now print the results for comparison ]
sl@0
    89
	for( TInt i = 0; i < length; i++ )
sl@0
    90
		{
sl@0
    91
        RDebug::Print( _L("difference: %d, coded: %d, RefCoded: %d"), (*ptr1-*ptr2), *ptr1++, *ptr2++ );
sl@0
    92
		} 
sl@0
    93
	}
sl@0
    94
sl@0
    95
/**
sl@0
    96
*
sl@0
    97
* AssembleValue
sl@0
    98
* @param aData src data buffer 
sl@0
    99
* @param aValue resultant value
sl@0
   100
* @param aBigEndian whether the value is in BigEndian format
sl@0
   101
* @precondition aData is not null and has length >= 2
sl@0
   102
*
sl@0
   103
*/
sl@0
   104
void CMMFDataGenerator::AssembleValue( TUint8* aData, TInt16& aValue, TBool aBigEndian )
sl@0
   105
	{
sl@0
   106
	__ASSERT_DEBUG( aData, Panic(EBadArgument));
sl@0
   107
    if( aBigEndian )
sl@0
   108
		{
sl@0
   109
		aValue  = static_cast<TInt16>( aData[1] &KAndMask8bit );  
sl@0
   110
		aValue |=  static_cast<TInt16>((aData[0] << 8 ));
sl@0
   111
		}
sl@0
   112
	else
sl@0
   113
		{
sl@0
   114
		aValue  = static_cast<TInt16>( aData[0] &KAndMask8bit);  
sl@0
   115
		aValue |=  static_cast<TInt16>((aData[1] << 8 ));
sl@0
   116
		}
sl@0
   117
	}
sl@0
   118
sl@0
   119
/**
sl@0
   120
*
sl@0
   121
* AssembleValue
sl@0
   122
* @param aData src data buffer 
sl@0
   123
* @param aValue resultant value
sl@0
   124
* @param aBigEndian whether the value is in BigEndian format
sl@0
   125
* @precondition aData is not null and has length >= 2
sl@0
   126
*
sl@0
   127
*/
sl@0
   128
void CMMFDataGenerator::AssembleValue( TUint8* aData, TUint16& aValue, TBool aBigEndian )
sl@0
   129
	{
sl@0
   130
	__ASSERT_DEBUG( aData, Panic(EBadArgument));
sl@0
   131
	if( aBigEndian )
sl@0
   132
		{
sl@0
   133
		aValue     = aData[1] ; //[ big endian format]
sl@0
   134
		aValue    |= (aData[0] << 8 ); 
sl@0
   135
		}
sl@0
   136
	else
sl@0
   137
		{
sl@0
   138
		aValue     = aData[0] ; 
sl@0
   139
		aValue    |= (aData[1] << 8 ); 
sl@0
   140
		}
sl@0
   141
	}
sl@0
   142
/**
sl@0
   143
*
sl@0
   144
* CMMFPcmU16toPcmU16BGenerator
sl@0
   145
*
sl@0
   146
**/
sl@0
   147
CMMFPcmU16toPcmU16BGenerator::CMMFPcmU16toPcmU16BGenerator()
sl@0
   148
	{
sl@0
   149
	}
sl@0
   150
sl@0
   151
/**
sl@0
   152
*
sl@0
   153
* ~CMMFPcmU16toPcmU16BGenerator
sl@0
   154
*
sl@0
   155
**/
sl@0
   156
CMMFPcmU16toPcmU16BGenerator::~CMMFPcmU16toPcmU16BGenerator()
sl@0
   157
	{
sl@0
   158
	}
sl@0
   159
sl@0
   160
/**
sl@0
   161
*
sl@0
   162
* GenerateSourceDataL
sl@0
   163
*
sl@0
   164
**/
sl@0
   165
void CMMFPcmU16toPcmU16BGenerator::GenerateSourceDataL( CMMFDataBuffer* &aBuffer, TInt aSize )
sl@0
   166
	{
sl@0
   167
	const TUint16 KScale2 = 32000;
sl@0
   168
sl@0
   169
	 //[ create a buffer large enough to fill with the data ]
sl@0
   170
	aBuffer = CMMFDescriptorBuffer::NewL(aSize);
sl@0
   171
sl@0
   172
	TUint8* pDst = CONST_CAST(TUint8*,aBuffer->Data().Ptr());
sl@0
   173
sl@0
   174
	//[ lets fill it with a 400hz signal at approx -3db ]
sl@0
   175
	//[encode the data]
sl@0
   176
	 TUint16 srcValue = 0;
sl@0
   177
	 TReal val   = 0.0;
sl@0
   178
	 TReal theta = 0.0; 
sl@0
   179
sl@0
   180
	 TInt noSamples = aSize/sizeof(TInt16);
sl@0
   181
	 for(TInt i=0; i< noSamples; i++)
sl@0
   182
		 {
sl@0
   183
		 //[ assign data and place in buffer]
sl@0
   184
		  theta = (KPi*i)/10; // fundamental of 400hz sampled @8khz has 20 db or
sl@0
   185
		                      // better reproduction through gsm codec
sl@0
   186
		  User::LeaveIfError(Math::Sin(val,theta));
sl@0
   187
          srcValue = static_cast<TUint16>( (KScale2 * val ) + KScale2+0.5);
sl@0
   188
          *pDst++ = static_cast<TUint8>( srcValue &KAndMask8bit);
sl@0
   189
		  *pDst++ = static_cast<TUint8>( (srcValue >>8) &KAndMask8bit);
sl@0
   190
		 }
sl@0
   191
    
sl@0
   192
	 aBuffer->Data().SetLength(aSize); 
sl@0
   193
	}
sl@0
   194
sl@0
   195
/**
sl@0
   196
*
sl@0
   197
* GenerateComparisonDataL
sl@0
   198
*
sl@0
   199
**/
sl@0
   200
void CMMFPcmU16toPcmU16BGenerator::GenerateComparisonDataL( CMMFDataBuffer* &aBuffer, TInt aSize )
sl@0
   201
	{
sl@0
   202
	const TUint16 KScale2 = 32000;
sl@0
   203
sl@0
   204
	 //[ create a buffer large eneough to fill with the data ]
sl@0
   205
	aBuffer = CMMFDescriptorBuffer::NewL(aSize);
sl@0
   206
sl@0
   207
	TUint8* pDst = CONST_CAST(TUint8*,aBuffer->Data().Ptr());
sl@0
   208
sl@0
   209
	//[ lets fill it with a 400hz signal at approx -3db ]
sl@0
   210
	//[encode the data]
sl@0
   211
	 TUint16 srcValue = 0;
sl@0
   212
	 TReal val   = 0.0;
sl@0
   213
	 TReal theta = 0.0; 
sl@0
   214
sl@0
   215
	 TInt noSamples = aSize/sizeof(TInt16);
sl@0
   216
	 for(TInt i=0; i< noSamples; i++)
sl@0
   217
		 {
sl@0
   218
		 //[ assign data and place in buffer]
sl@0
   219
		  theta = (KPi*i)/10; // fundamental of 400hz sampled @8khz has 20 db or
sl@0
   220
		                      // better reproduction through gsm codec
sl@0
   221
		  User::LeaveIfError(Math::Sin(val,theta));
sl@0
   222
          srcValue = static_cast<TUint16>( (KScale2 * val)+KScale2 +0.5);
sl@0
   223
          //[endian swap here ]
sl@0
   224
		  *pDst++ = static_cast<TUint8>( (srcValue >>8) &KAndMask8bit);
sl@0
   225
		  *pDst++ = static_cast<TUint8>( srcValue &KAndMask8bit);
sl@0
   226
		 }
sl@0
   227
    
sl@0
   228
	 aBuffer->Data().SetLength(aSize); 
sl@0
   229
	}
sl@0
   230
sl@0
   231
/**
sl@0
   232
*
sl@0
   233
* PrintComparisonDataL
sl@0
   234
* Prints out coded results for comparison with the 
sl@0
   235
* Reference values and is used when the results differ
sl@0
   236
*
sl@0
   237
**/
sl@0
   238
void CMMFPcmU16toPcmU16BGenerator::PrintComparisonDataL( CMMFDataBuffer& aCodedData, CMMFDataBuffer& aRefCodedData )
sl@0
   239
	{
sl@0
   240
	//[precondition reference coded data is equal in size or longer than coded data ]
sl@0
   241
	if( aRefCodedData.Data().Length() < aCodedData.Data().Length() )
sl@0
   242
		{
sl@0
   243
         //[coded data is longer than reference data]
sl@0
   244
	//	RDebug::Print( _L("Coded Data is longer than refernce data"));Commented under DEF105143
sl@0
   245
		User::Leave( KErrCorrupt );	 
sl@0
   246
		}
sl@0
   247
sl@0
   248
	//[ now print the results for comparison ]
sl@0
   249
    TUint8* ptr1 = CONST_CAST(TUint8*, aCodedData.Data().Ptr());
sl@0
   250
	TUint8* ptr2 = CONST_CAST(TUint8*, aRefCodedData.Data().Ptr());
sl@0
   251
    TInt length = aCodedData.Data().Length();
sl@0
   252
	length /= 2; // [for 16bit words length is half]
sl@0
   253
	//[ assert invariant length is even ]
sl@0
   254
	__ASSERT_DEBUG( (length % 2 == 0 ), Panic(EBadInvariant));
sl@0
   255
sl@0
   256
	TUint16 codedValue = 0;
sl@0
   257
	TUint16 refCodedValue = 0;
sl@0
   258
	//[ now print the results for comparison ]
sl@0
   259
	for( TInt i = 0; i < length; i++ )
sl@0
   260
		{
sl@0
   261
		//[ assemble 16bit values from buffer values ]    
sl@0
   262
		AssembleValue( ptr1, codedValue, ETrue );
sl@0
   263
		AssembleValue( ptr2, refCodedValue, ETrue );       
sl@0
   264
		RDebug::Print( _L("difference: %u, coded: %u, RefCoded: %u"), (refCodedValue-codedValue), codedValue, refCodedValue );
sl@0
   265
		if( i % 100 == 0 ) //deal with debug printf deficiencies
sl@0
   266
			{
sl@0
   267
			User::After(100 );
sl@0
   268
			}
sl@0
   269
		ptr1+=2;
sl@0
   270
		ptr2+=2;
sl@0
   271
		} 
sl@0
   272
 	}
sl@0
   273
sl@0
   274
/**
sl@0
   275
*
sl@0
   276
* CMMFPcmU16BtoPcmU16Generator
sl@0
   277
*
sl@0
   278
**/
sl@0
   279
CMMFPcmU16BtoPcmU16Generator::CMMFPcmU16BtoPcmU16Generator()
sl@0
   280
	{
sl@0
   281
	}
sl@0
   282
sl@0
   283
/**
sl@0
   284
*
sl@0
   285
* ~CMMFPcmU16BtoPcmU16Generator
sl@0
   286
*
sl@0
   287
**/
sl@0
   288
CMMFPcmU16BtoPcmU16Generator::~CMMFPcmU16BtoPcmU16Generator()
sl@0
   289
	{
sl@0
   290
	}
sl@0
   291
sl@0
   292
/**
sl@0
   293
*
sl@0
   294
* GenerateSourceDataL
sl@0
   295
*
sl@0
   296
**/
sl@0
   297
void CMMFPcmU16BtoPcmU16Generator::GenerateSourceDataL( CMMFDataBuffer* &aBuffer, TInt aSize )
sl@0
   298
	{
sl@0
   299
	const TUint8 KScale2 = 127;
sl@0
   300
sl@0
   301
	 //[ create a buffer large eneough to fill with the data ]
sl@0
   302
	aBuffer = CMMFDescriptorBuffer::NewL(aSize);
sl@0
   303
sl@0
   304
	TUint8* pDst = CONST_CAST(TUint8*,aBuffer->Data().Ptr());
sl@0
   305
sl@0
   306
	//[ lets fill it with a 400hz signal at approx -3db ]
sl@0
   307
	//[encode the data]
sl@0
   308
	 TInt8 srcValue = 0;
sl@0
   309
	 TReal val   = 0.0;
sl@0
   310
	 TReal theta = 0.0; 
sl@0
   311
sl@0
   312
	 TInt noSamples = aSize/sizeof(TInt16);
sl@0
   313
	 for(TInt i=0; i< noSamples; i++)
sl@0
   314
		 {
sl@0
   315
		 //[ assign data and place in buffer]
sl@0
   316
		  theta = (KPi*i)/10; // fundamental of 400hz sampled @8khz has 20 db or
sl@0
   317
		                      // better reproduction through gsm codec
sl@0
   318
		  User::LeaveIfError(Math::Sin(val,theta));
sl@0
   319
          srcValue = static_cast<TUint8>( (KScale2 * val) );
sl@0
   320
          //[endian swap here ]
sl@0
   321
		  *pDst++ = static_cast<TUint8>( (srcValue >>8) &KAndMask8bit);
sl@0
   322
		  *pDst++ = static_cast<TUint8>( srcValue &KAndMask8bit);
sl@0
   323
		 }
sl@0
   324
    
sl@0
   325
	 aBuffer->Data().SetLength(aSize); 
sl@0
   326
	}
sl@0
   327
sl@0
   328
/**
sl@0
   329
*
sl@0
   330
* GenerateComparisonDataL
sl@0
   331
*
sl@0
   332
**/
sl@0
   333
void CMMFPcmU16BtoPcmU16Generator::GenerateComparisonDataL( CMMFDataBuffer* &aBuffer, TInt aSize )
sl@0
   334
	{
sl@0
   335
	const TUint8 KScale2 = 127;
sl@0
   336
sl@0
   337
	 //[ create a buffer large eneough to fill with the data ]
sl@0
   338
	aBuffer = CMMFDescriptorBuffer::NewL(aSize);
sl@0
   339
sl@0
   340
	TUint8* pDst = CONST_CAST(TUint8*,aBuffer->Data().Ptr());
sl@0
   341
sl@0
   342
	//[ lets fill it with a 400hz signal at approx -3db ]
sl@0
   343
	//[encode the data]
sl@0
   344
	 TUint16 srcValue = 0;
sl@0
   345
	 TReal val   = 0.0;
sl@0
   346
	 TReal theta = 0.0; 
sl@0
   347
	 TInt noSamples = aSize/sizeof(TInt16);
sl@0
   348
	 for(TInt i=0; i< noSamples; i++)
sl@0
   349
		 {
sl@0
   350
		 //[ assign data and place in buffer]
sl@0
   351
		  theta = (KPi*i)/10; // fundamental of 400hz sampled @8khz has 20 db or
sl@0
   352
		                      // better reproduction through gsm codec
sl@0
   353
		  User::LeaveIfError(Math::Sin(val,theta));
sl@0
   354
          srcValue = static_cast<TUint16>( KScale2 * val );
sl@0
   355
		  *pDst++ = static_cast<TUint8>( srcValue &KAndMask8bit);
sl@0
   356
		  *pDst++ = static_cast<TUint8>( (srcValue >>8) &KAndMask8bit);
sl@0
   357
		 }
sl@0
   358
    
sl@0
   359
	 aBuffer->Data().SetLength(aSize); 
sl@0
   360
	}
sl@0
   361
sl@0
   362
/**
sl@0
   363
*
sl@0
   364
* PrintComparisonDataL
sl@0
   365
* Prints out coded results for comparison with the 
sl@0
   366
* Reference values and is used when the results differ
sl@0
   367
*
sl@0
   368
**/
sl@0
   369
void CMMFPcmU16BtoPcmU16Generator::PrintComparisonDataL( CMMFDataBuffer& aCodedData, CMMFDataBuffer& aRefCodedData )
sl@0
   370
	{
sl@0
   371
	//[precondition reference coded data is equal in size or longer than coded data ]
sl@0
   372
	if( aRefCodedData.Data().Length() < aCodedData.Data().Length() )
sl@0
   373
		{
sl@0
   374
		//[coded data is longer than reference data]
sl@0
   375
	//	RDebug::Print( _L("Coded Data is longer than refernce data"));Commented under DEF105143
sl@0
   376
		User::Leave( KErrCorrupt );	 
sl@0
   377
		}
sl@0
   378
	
sl@0
   379
	//[ now print the results for comparison ]
sl@0
   380
    TUint8* ptr1 = CONST_CAST(TUint8*, aCodedData.Data().Ptr());
sl@0
   381
	TUint8* ptr2 = CONST_CAST(TUint8*, aRefCodedData.Data().Ptr());
sl@0
   382
    TInt length = aCodedData.Data().Length();
sl@0
   383
	length /= 2; //[ for 16bit words ]
sl@0
   384
	TUint16 codedValue = 0;
sl@0
   385
	TUint16 refCodedValue = 0;
sl@0
   386
	//[ now print the results for comparison ]
sl@0
   387
	for( TInt i = 0; i < length; i++ )
sl@0
   388
		{
sl@0
   389
		// assemble 16bit values
sl@0
   390
		AssembleValue( ptr1, codedValue, EFalse);
sl@0
   391
		AssembleValue( ptr2, refCodedValue, EFalse );        
sl@0
   392
		RDebug::Print( _L("difference: %u, coded: %u, RefCoded: %u"), (refCodedValue-codedValue), codedValue, refCodedValue );
sl@0
   393
		if( i % 100 == 0 ) //deal with debug printf deficiencies
sl@0
   394
			{
sl@0
   395
			User::After( 100 );
sl@0
   396
			}
sl@0
   397
		ptr1+=2;
sl@0
   398
		ptr2+=2;
sl@0
   399
		} 	
sl@0
   400
	}
sl@0
   401
sl@0
   402
/**
sl@0
   403
*
sl@0
   404
* CMMFPcm8ToPcm16Generator
sl@0
   405
*
sl@0
   406
**/
sl@0
   407
CMMFPcm8ToPcm16Generator::CMMFPcm8ToPcm16Generator()
sl@0
   408
	{
sl@0
   409
	}
sl@0
   410
sl@0
   411
/**
sl@0
   412
*
sl@0
   413
* CMMFPcm8ToPcm16Generator
sl@0
   414
*
sl@0
   415
**/
sl@0
   416
CMMFPcm8ToPcm16Generator::~CMMFPcm8ToPcm16Generator()
sl@0
   417
	{
sl@0
   418
	}
sl@0
   419
sl@0
   420
/**
sl@0
   421
*
sl@0
   422
* GenerateSourceDataL
sl@0
   423
*
sl@0
   424
**/
sl@0
   425
void CMMFPcm8ToPcm16Generator::GenerateSourceDataL( CMMFDataBuffer* &aBuffer, TInt aSize )
sl@0
   426
	{
sl@0
   427
	const TInt8 KScale2 = 127;
sl@0
   428
sl@0
   429
	 //[ create a buffer large eneough to fill with the data ]
sl@0
   430
	aBuffer = CMMFDescriptorBuffer::NewL(aSize);
sl@0
   431
sl@0
   432
	TUint8* pDst = CONST_CAST(TUint8*,aBuffer->Data().Ptr());
sl@0
   433
sl@0
   434
	//[ lets fill it with a 400hz signal at approx -3db ]
sl@0
   435
	//[encode the data]
sl@0
   436
	 TInt8 srcValue = 0;
sl@0
   437
	 TReal val   = 0.0;
sl@0
   438
	 TReal theta = 0.0; 
sl@0
   439
     TInt noSamples = aSize/sizeof(TInt8);
sl@0
   440
	 for(TInt i=0; i< noSamples; i++)
sl@0
   441
		 {
sl@0
   442
		 //[ assign data and place in buffer]
sl@0
   443
		  theta = (KPi*i)/10; // fundamental of 400hz sampled @8khz has 20 db or
sl@0
   444
		                      // better reproduction through gsm codec
sl@0
   445
		  User::LeaveIfError(Math::Sin(val,theta));
sl@0
   446
          srcValue = static_cast<TInt8>( (KScale2 * val) );
sl@0
   447
          *pDst++ = srcValue;
sl@0
   448
		 }
sl@0
   449
    
sl@0
   450
	 aBuffer->Data().SetLength(aSize); 
sl@0
   451
	}
sl@0
   452
sl@0
   453
/**
sl@0
   454
*
sl@0
   455
* GenerateSourceDataL
sl@0
   456
*
sl@0
   457
**/
sl@0
   458
void CMMFPcm8ToPcm16Generator::GenerateComparisonDataL( CMMFDataBuffer* &aBuffer, TInt aSize )
sl@0
   459
	{
sl@0
   460
	const TInt8 KScale2 = 127;
sl@0
   461
sl@0
   462
	 //[ create a buffer large eneough to fill with the data ]
sl@0
   463
	aBuffer = CMMFDescriptorBuffer::NewL(aSize);
sl@0
   464
sl@0
   465
	TUint8* pDst = CONST_CAST(TUint8*,aBuffer->Data().Ptr());
sl@0
   466
sl@0
   467
	//[ lets fill it with a 400hz signal at approx -3db ]
sl@0
   468
	//[encode the data]
sl@0
   469
	 TInt16 srcValue = 0;
sl@0
   470
	 TReal val   = 0.0;
sl@0
   471
	 TReal theta = 0.0; 
sl@0
   472
	 TInt noSamples = aSize/sizeof(TInt16);
sl@0
   473
	 for(TInt i=0; i< noSamples; i++)
sl@0
   474
		 {
sl@0
   475
		 //[ assign data and place in buffer]
sl@0
   476
		  theta = (KPi*i)/10; // fundamental of 400hz sampled @8khz has 20 db or
sl@0
   477
		                      // better reproduction through gsm codec
sl@0
   478
		  User::LeaveIfError(Math::Sin(val,theta));
sl@0
   479
		  TInt8 temp = static_cast<TInt8>((KScale2 * val));
sl@0
   480
          srcValue =  static_cast<TInt16>( temp << 8); 
sl@0
   481
		  *pDst++ = static_cast<TInt8>( srcValue&KAndMask8bit);
sl@0
   482
		  *pDst++ = static_cast<TInt8>((srcValue>>8)&KAndMask8bit);
sl@0
   483
		 }
sl@0
   484
    
sl@0
   485
	 aBuffer->Data().SetLength(aSize); 
sl@0
   486
	}
sl@0
   487
sl@0
   488
/**
sl@0
   489
*
sl@0
   490
* PrintComparisonDataL
sl@0
   491
* Prints out coded results for comparison with the 
sl@0
   492
* Reference values and is used when the results differ
sl@0
   493
*
sl@0
   494
**/
sl@0
   495
void CMMFPcm8ToPcm16Generator::PrintComparisonDataL( CMMFDataBuffer& aCodedData, CMMFDataBuffer& aRefCodedData )
sl@0
   496
	{
sl@0
   497
	//[precondition reference coded data is equal in size or longer than coded data ]
sl@0
   498
	if( aRefCodedData.Data().Length() < aCodedData.Data().Length() )
sl@0
   499
		{
sl@0
   500
		//[coded data is longer than reference data]
sl@0
   501
	//	RDebug::Print( _L("Coded Data is longer than refernce data"));Commented under DEF105143
sl@0
   502
		User::Leave( KErrCorrupt );	 
sl@0
   503
		}
sl@0
   504
	
sl@0
   505
	//[ now print the results for comparison ]
sl@0
   506
    TUint8* ptr1 = CONST_CAST(TUint8*, aCodedData.Data().Ptr());
sl@0
   507
	TUint8* ptr2 = CONST_CAST(TUint8*, aRefCodedData.Data().Ptr());
sl@0
   508
    TInt length = aCodedData.Data().Length();
sl@0
   509
	length /= 2; //[ for 16bit words ]
sl@0
   510
	TInt16 codedValue = 0;
sl@0
   511
	TInt16 refCodedValue = 0;
sl@0
   512
	//[ now print the results for comparison ]
sl@0
   513
	for( TInt i = 0; i < length; i++ )
sl@0
   514
		{
sl@0
   515
		// assemble 16bit values
sl@0
   516
  		AssembleValue( ptr1, codedValue, EFalse );
sl@0
   517
		AssembleValue( ptr2, refCodedValue, EFalse );        
sl@0
   518
		RDebug::Print( _L("difference: %d, coded: %d, RefCoded: %d"), (refCodedValue-codedValue), codedValue, refCodedValue );
sl@0
   519
		if( i % 100 == 0 ) //deal with debug printf deficiencies
sl@0
   520
			{
sl@0
   521
			User::After(100 );
sl@0
   522
			}
sl@0
   523
		ptr1+=2;
sl@0
   524
		ptr2+=2;
sl@0
   525
		} 	
sl@0
   526
	}
sl@0
   527
sl@0
   528
/**
sl@0
   529
*
sl@0
   530
* CMMFPcmU8ToPcm16Generator
sl@0
   531
*
sl@0
   532
**/
sl@0
   533
CMMFPcmU8ToPcm16Generator::CMMFPcmU8ToPcm16Generator()
sl@0
   534
	 {
sl@0
   535
	 }
sl@0
   536
sl@0
   537
/**
sl@0
   538
*
sl@0
   539
* ~CMMFPcmU8ToPcm16Generator
sl@0
   540
*
sl@0
   541
**/
sl@0
   542
CMMFPcmU8ToPcm16Generator::~CMMFPcmU8ToPcm16Generator()
sl@0
   543
	 {
sl@0
   544
	 }
sl@0
   545
sl@0
   546
/**
sl@0
   547
*
sl@0
   548
* GenerateSourceDataL
sl@0
   549
* @param aBuffer
sl@0
   550
* @param aSize in bytes
sl@0
   551
*
sl@0
   552
**/
sl@0
   553
void CMMFPcmU8ToPcm16Generator::GenerateSourceDataL( CMMFDataBuffer* &aBuffer, TInt aSize )
sl@0
   554
	 {
sl@0
   555
	 const TUint8 KScale2 = 127;
sl@0
   556
sl@0
   557
	 //[ create a buffer large eneough to fill with the data ]
sl@0
   558
	aBuffer = CMMFDescriptorBuffer::NewL(aSize);
sl@0
   559
sl@0
   560
	TUint8* pDst = CONST_CAST(TUint8*,aBuffer->Data().Ptr());
sl@0
   561
sl@0
   562
	//[ lets fill it with a 400hz signal at approx -3db ]
sl@0
   563
	//[encode the data]
sl@0
   564
	 TUint8 srcValue = 0;
sl@0
   565
	 TReal val   = 0.0;
sl@0
   566
	 TReal theta = 0.0; 
sl@0
   567
	 TInt noSamples = aSize/sizeof(TUint8);
sl@0
   568
	 for(TInt i=0; i< noSamples; i++)
sl@0
   569
		 {
sl@0
   570
		 //[ assign data and place in buffer]
sl@0
   571
		  theta = KPi*i/10; // fundamental of 400hz sampled @8khz has 20 db or
sl@0
   572
		                      // better reproduction through gsm codec
sl@0
   573
		  User::LeaveIfError(Math::Sin(val,theta));
sl@0
   574
sl@0
   575
          srcValue = static_cast<TUint8>((KScale2 * val+KScale2+0.5));
sl@0
   576
          *pDst++ = srcValue;
sl@0
   577
		   //RDebug::Print( _L("U8 = %u"), srcValue );  Statement commented under DEf105143
sl@0
   578
		 }
sl@0
   579
    
sl@0
   580
	 aBuffer->Data().SetLength(aSize); 
sl@0
   581
	 }
sl@0
   582
sl@0
   583
/**
sl@0
   584
*
sl@0
   585
* GenerateComparisonDataL
sl@0
   586
* @param aBuffer
sl@0
   587
* @param aSize
sl@0
   588
*
sl@0
   589
**/
sl@0
   590
void CMMFPcmU8ToPcm16Generator::GenerateComparisonDataL( CMMFDataBuffer* &aBuffer, TInt aSize )
sl@0
   591
	{
sl@0
   592
	const TInt8 KScale2 = 127;
sl@0
   593
	
sl@0
   594
	//[ create a buffer large eneough to fill with the data ]
sl@0
   595
	aBuffer = CMMFDescriptorBuffer::NewL(aSize);
sl@0
   596
	
sl@0
   597
	TUint8* pDst = CONST_CAST(TUint8*,aBuffer->Data().Ptr());
sl@0
   598
	
sl@0
   599
	//[ lets fill it with a 400hz signal at approx -3db ]
sl@0
   600
	//[encode the data]
sl@0
   601
//	RDebug::Print( _L("Generation"));Commented under DEF105143
sl@0
   602
	TUint8 theValue = 0;
sl@0
   603
	TReal val   = 0.0;
sl@0
   604
	TReal theta = 0.0; 
sl@0
   605
	TUint8 rrr  = 0;
sl@0
   606
	TInt length = aSize/sizeof(TInt16);
sl@0
   607
	for(TInt i=0; i< length; i++)
sl@0
   608
		{
sl@0
   609
		//[ assign data and place in buffer]
sl@0
   610
		theta = KPi*i/10; // fundamental of 400hz sampled @8khz has 20 db or
sl@0
   611
		// better reproduction through gsm codec
sl@0
   612
		User::LeaveIfError(Math::Sin(val,theta));
sl@0
   613
		theValue = static_cast<TUint8>(KScale2 *val + KScale2 + 0.5); 
sl@0
   614
		//[ apply the same transformation as the codec ]
sl@0
   615
		rrr = static_cast<TUint8>( theValue^KMaskSign8bit );
sl@0
   616
		//RDebug::Print( _L("U8 = %u"), theValue ); Statement commented under DEf105143
sl@0
   617
		*pDst++ = rrr;
sl@0
   618
		*pDst++ = rrr;
sl@0
   619
		}
sl@0
   620
    
sl@0
   621
	aBuffer->Data().SetLength(aSize); 
sl@0
   622
	}
sl@0
   623
sl@0
   624
/**
sl@0
   625
*
sl@0
   626
* PrintComparisonDataL
sl@0
   627
* Prints out coded results for comparison with the 
sl@0
   628
* Reference values and is used when the results differ
sl@0
   629
*
sl@0
   630
**/
sl@0
   631
void CMMFPcmU8ToPcm16Generator::PrintComparisonDataL( CMMFDataBuffer& aCodedData, CMMFDataBuffer& aRefCodedData )
sl@0
   632
	{
sl@0
   633
	//[precondition reference coded data is equal in size or longer than coded data ]
sl@0
   634
	if( aRefCodedData.Data().Length() < aCodedData.Data().Length() )
sl@0
   635
		{
sl@0
   636
		//[coded data is longer than reference data]
sl@0
   637
	//	RDebug::Print( _L("Coded Data is longer than reference data"));Commented under DEF105143
sl@0
   638
		User::Leave( KErrCorrupt );	 
sl@0
   639
		}
sl@0
   640
	
sl@0
   641
	//[ now print the results for comparison ]
sl@0
   642
    TUint8* ptr1 = CONST_CAST(TUint8*, aCodedData.Data().Ptr());
sl@0
   643
	TUint8* ptr2 = CONST_CAST(TUint8*, aRefCodedData.Data().Ptr());
sl@0
   644
    TInt length = aCodedData.Data().Length();
sl@0
   645
	length /= 2; //[ for 16bit words ]
sl@0
   646
	TInt16 codedValue = 0;
sl@0
   647
	TInt16 refCodedValue = 0;
sl@0
   648
	//[ now print the results for comparison ]
sl@0
   649
	for( TInt i = 0; i < length; i++ )
sl@0
   650
		{
sl@0
   651
		// assemble 16bit values
sl@0
   652
  		AssembleValue( ptr1, codedValue, EFalse );
sl@0
   653
		AssembleValue( ptr2, refCodedValue, EFalse );        
sl@0
   654
		RDebug::Print( _L("delta %d c %d, rf %d"), (refCodedValue-codedValue), codedValue, refCodedValue );
sl@0
   655
		if( i % 100 == 0 ) //deal with debug printf deficiencies
sl@0
   656
			{
sl@0
   657
			User::After(100 );
sl@0
   658
			}
sl@0
   659
		ptr1+=2;
sl@0
   660
		ptr2+=2;
sl@0
   661
		} 
sl@0
   662
sl@0
   663
	}
sl@0
   664
sl@0
   665
/**
sl@0
   666
*
sl@0
   667
* CMMFPcm16ToPcmU8Generator
sl@0
   668
*
sl@0
   669
**/
sl@0
   670
CMMFPcm16ToPcmU8Generator::CMMFPcm16ToPcmU8Generator()
sl@0
   671
	{
sl@0
   672
     //Nothing doing
sl@0
   673
	}
sl@0
   674
sl@0
   675
/**
sl@0
   676
*
sl@0
   677
* CMMFPcm16ToPcmU8Generator
sl@0
   678
*
sl@0
   679
**/
sl@0
   680
CMMFPcm16ToPcmU8Generator::~CMMFPcm16ToPcmU8Generator()
sl@0
   681
	{
sl@0
   682
     //Nothing doing
sl@0
   683
	}
sl@0
   684
sl@0
   685
/**
sl@0
   686
*
sl@0
   687
* GenerateSourceDataL
sl@0
   688
* @param aBuffer
sl@0
   689
* @param aSize in bytes
sl@0
   690
* This function generates a 400hz sine wav
sl@0
   691
* under the assumption the sampling frequency is 8khz
sl@0
   692
*
sl@0
   693
*/
sl@0
   694
void CMMFPcm16ToPcmU8Generator::GenerateSourceDataL( CMMFDataBuffer* &aBuffer, TInt aSize )
sl@0
   695
	{
sl@0
   696
	const TInt KScale = 320;
sl@0
   697
sl@0
   698
	 //[ create a buffer large eneough to fill with the data ]
sl@0
   699
	aBuffer = CMMFDescriptorBuffer::NewL(aSize);
sl@0
   700
sl@0
   701
	TUint8* pDst = CONST_CAST(TUint8*,aBuffer->Data().Ptr());
sl@0
   702
sl@0
   703
	//[ lets fill it with a 400hz signal at approx -3db ]
sl@0
   704
	//[encode the data]
sl@0
   705
	 TInt16 srcValue = 0;
sl@0
   706
	 TReal val   = 0.0;
sl@0
   707
	 TReal theta = 0.0; 
sl@0
   708
	 TInt noSamples = aSize/sizeof(TInt16);
sl@0
   709
	 for(TInt i=0; i< noSamples; i++)
sl@0
   710
		 {
sl@0
   711
		 //[ assign data and place in buffer]
sl@0
   712
		  theta = (KPi*i)/10; // fundamental of 400hz sampled @8khz has 20 db or
sl@0
   713
		                      // better reproduction through gsm codec
sl@0
   714
		  User::LeaveIfError(Math::Sin(val,theta));
sl@0
   715
          srcValue = static_cast<TInt16>( KScale * val );
sl@0
   716
          *pDst++ = static_cast<TUint8>( srcValue & KAndMask8bit);
sl@0
   717
		  *pDst++ = static_cast<TUint8>((srcValue >> 8) & KAndMask8bit );
sl@0
   718
		 }
sl@0
   719
    
sl@0
   720
	 aBuffer->Data().SetLength(aSize); 
sl@0
   721
	}
sl@0
   722
sl@0
   723
/**
sl@0
   724
*
sl@0
   725
* GenerateComparisonDataL
sl@0
   726
* @param aBuffer
sl@0
   727
* @param aSize in bytes
sl@0
   728
* This function generates a 400hz sine wav
sl@0
   729
* under the assumption the sampling frequency is 8khz
sl@0
   730
*/
sl@0
   731
//[ use partial sopecialization to provide copncrete implmentation]
sl@0
   732
void CMMFPcm16ToPcmU8Generator::GenerateComparisonDataL( CMMFDataBuffer* &aBuffer, TInt aSize )
sl@0
   733
	{
sl@0
   734
	const TInt KScale2 = 320; //low value chosen to emphasize the distortion of this codec!
sl@0
   735
sl@0
   736
	 //[ create a buffer large eneough to fill with the data ]
sl@0
   737
	aBuffer = CMMFDescriptorBuffer::NewL(aSize);
sl@0
   738
sl@0
   739
	TUint8* pDst = CONST_CAST(TUint8*,aBuffer->Data().Ptr());
sl@0
   740
sl@0
   741
	//[ lets fill it with a 400hz signal at approx -3db ]
sl@0
   742
	//[encode the data]
sl@0
   743
	 TInt16 srcValue = 0;
sl@0
   744
	 TReal val   = 0.0;
sl@0
   745
	 TReal theta = 0.0; 
sl@0
   746
	 TInt noSamples = aSize/sizeof(TUint8);
sl@0
   747
	 for(TInt i=0; i< noSamples; i++)
sl@0
   748
		 {
sl@0
   749
		 //[ assign data and place in buffer]
sl@0
   750
		  theta = (KPi*i)/10; // fundamental of 400hz sampled @8khz has 20 db or
sl@0
   751
		                      // better reproduction through gsm codec
sl@0
   752
		  User::LeaveIfError(Math::Sin(val,theta));
sl@0
   753
          srcValue = static_cast<TInt16>( KScale2 * val );
sl@0
   754
          *pDst++ = static_cast<TUint8>( (srcValue >> 8) - KMaskSign8bit);
sl@0
   755
		 }
sl@0
   756
    
sl@0
   757
	 aBuffer->Data().SetLength(aSize); 
sl@0
   758
	}
sl@0
   759
sl@0
   760
/**
sl@0
   761
*
sl@0
   762
* PrintComparisonDataL
sl@0
   763
* Prints out coded results for comparison with the 
sl@0
   764
* Reference values and is used when the results differ
sl@0
   765
*
sl@0
   766
**/
sl@0
   767
void CMMFPcm16ToPcmU8Generator::PrintComparisonDataL( CMMFDataBuffer& aCodedData, CMMFDataBuffer& aRefCodedData )
sl@0
   768
	{
sl@0
   769
	//[precondition reference coded data is equal in size or longer than coded data ]
sl@0
   770
	if( aRefCodedData.Data().Length() < aCodedData.Data().Length() )
sl@0
   771
		{
sl@0
   772
         //[coded data is longer than reference data]
sl@0
   773
	//	RDebug::Print( _L("Coded Data is longer than refernce data"));Commented under DEF105143
sl@0
   774
		User::Leave( KErrCorrupt );	 
sl@0
   775
		}
sl@0
   776
sl@0
   777
	//[ now print the results for comparison ]
sl@0
   778
    TUint8* ptr1 = CONST_CAST(TUint8*, aCodedData.Data().Ptr());
sl@0
   779
	TUint8* ptr2 = CONST_CAST(TUint8*, aRefCodedData.Data().Ptr());
sl@0
   780
    TInt length = aCodedData.Data().Length();
sl@0
   781
	//[ now print the results for comparison ]
sl@0
   782
	for( TInt i = 0; i < length; i++ )
sl@0
   783
		{
sl@0
   784
		RDebug::Print( _L("difference: %u, coded: %u, RefCoded: %u"), (*ptr1-*ptr2), *ptr1, *ptr2 );
sl@0
   785
		if( i % 100 == 0 ) //deal with debug printf deficiencies
sl@0
   786
			{
sl@0
   787
			User::After(100 );
sl@0
   788
			}
sl@0
   789
		ptr1++;
sl@0
   790
		ptr2++;
sl@0
   791
		} 
sl@0
   792
	}
sl@0
   793
sl@0
   794
/**
sl@0
   795
*
sl@0
   796
* CompareData
sl@0
   797
* @param aData1 first data buffer for comparison
sl@0
   798
* @param aData2 second data buffer for comparison
sl@0
   799
* result TBool data is the same
sl@0
   800
* @precondition aData1 has the same amount of data as aData2
sl@0
   801
*
sl@0
   802
*/
sl@0
   803
template <class T, class Generator, TInt index>
sl@0
   804
TBool CTestStepSignConversionTest<T, Generator, index>::CompareData( CMMFDataBuffer* aData1, CMMFDataBuffer* aData2)
sl@0
   805
	{
sl@0
   806
	TBool result = ETrue;
sl@0
   807
sl@0
   808
	//[ precondition aData1 != NULL ]
sl@0
   809
	if( !aData1 )
sl@0
   810
		{
sl@0
   811
		User::Leave( KErrArgument );
sl@0
   812
		}
sl@0
   813
sl@0
   814
    //[ precondition aData2 != NULL ]
sl@0
   815
	if( !aData2 )
sl@0
   816
		{
sl@0
   817
		User::Leave( KErrArgument );
sl@0
   818
		}
sl@0
   819
sl@0
   820
    //[precondition aData1 length == aData2 length ]
sl@0
   821
	if( aData1->Data().Length() != aData2->Data().Length() )
sl@0
   822
		{
sl@0
   823
		User::Leave( KErrArgument );
sl@0
   824
		}
sl@0
   825
sl@0
   826
	//[Now Compare the data]
sl@0
   827
	TUint8* ptr1 = CONST_CAST(TUint8*, aData1->Data().Ptr());
sl@0
   828
	TUint8* ptr2 = CONST_CAST(TUint8*, aData2->Data().Ptr());
sl@0
   829
	TInt dataLength = aData2->Data().Length();
sl@0
   830
   	if( Mem::Compare( ptr1, dataLength, ptr2, dataLength )!=0)
sl@0
   831
		{
sl@0
   832
		TUint8* p1 = ptr1; 
sl@0
   833
        TUint8* p2 = ptr2;
sl@0
   834
		TInt16 s1  = 0;
sl@0
   835
		TInt16 s2  = 0;
sl@0
   836
		INFO_PRINTF1(_L("------------------------------"));
sl@0
   837
		for( TInt i = 0; i < dataLength/2; i++ )
sl@0
   838
			{
sl@0
   839
		    s1  = static_cast<TInt16>( p1[0] &KAndMask8bit);  
sl@0
   840
		    s1 |=  static_cast<TInt16>((p1[1] << 8 ));
sl@0
   841
		    s2  = static_cast<TInt16>( p2[0] &KAndMask8bit);  
sl@0
   842
		    s2 |=  static_cast<TInt16>((p2[1] << 8 ));
sl@0
   843
			INFO_PRINTF3(_L("%d  %d"), s1, s2);
sl@0
   844
			p1+=2;
sl@0
   845
			p2+=2;
sl@0
   846
			}
sl@0
   847
		INFO_PRINTF1(_L("------------------------------"));
sl@0
   848
	//	RDebug::Print( _L("Comparison has failed")); Commented under DEF105143
sl@0
   849
		iGenerator->PrintComparisonDataL( *aData1, *aData2 );
sl@0
   850
		result = EFalse ;
sl@0
   851
		}
sl@0
   852
	return result;
sl@0
   853
	}
sl@0
   854
sl@0
   855
/**
sl@0
   856
*
sl@0
   857
* DoTestStepL
sl@0
   858
* @result TVerdict
sl@0
   859
*
sl@0
   860
*/
sl@0
   861
template <class T, class Generator, TInt index>
sl@0
   862
TVerdict CTestStepSignConversionTest<T, Generator, index>::DoTestStepL()
sl@0
   863
	{
sl@0
   864
	__MM_HEAP_MARK;	
sl@0
   865
	TVerdict result = EPass;
sl@0
   866
sl@0
   867
	//[pre condition iSourceData ]
sl@0
   868
	if( !iSourceData )
sl@0
   869
		{
sl@0
   870
		INFO_PRINTF1(_L("Source Data Failure"));
sl@0
   871
		User::Leave( KErrCorrupt);
sl@0
   872
		}
sl@0
   873
	//[precondition iCodedData  ]
sl@0
   874
	if( !iCodedData )
sl@0
   875
		{
sl@0
   876
		INFO_PRINTF1(_L("Coded Data Failure"));
sl@0
   877
		User::Leave( KErrCorrupt);
sl@0
   878
		}
sl@0
   879
	//[precondition iRefData ]
sl@0
   880
	if( !iRefCodedData )
sl@0
   881
		{
sl@0
   882
		INFO_PRINTF1(_L("RefCodedData Argument Failure"));
sl@0
   883
		User::Leave( KErrCorrupt);
sl@0
   884
		}
sl@0
   885
sl@0
   886
	//[ lets code the data and compare it to the reference data ]
sl@0
   887
    iCodecUnderTest->ProcessL(*iSourceData, *iCodedData);
sl@0
   888
    if(!CompareData(iCodedData, iRefCodedData))
sl@0
   889
		{
sl@0
   890
		INFO_PRINTF1(_L("Coded Results do not match reference coded results"));
sl@0
   891
sl@0
   892
		result = EFail;
sl@0
   893
		}
sl@0
   894
	
sl@0
   895
	__MM_HEAP_MARKEND;
sl@0
   896
	return result;
sl@0
   897
	}
sl@0
   898
sl@0
   899
/**
sl@0
   900
*
sl@0
   901
* DoTestStepPostambleL
sl@0
   902
* @result TVerdict
sl@0
   903
*
sl@0
   904
*/
sl@0
   905
template <class T, class Generator, TInt index>
sl@0
   906
TVerdict CTestStepSignConversionTest<T, Generator, index>::DoTestStepPostambleL()
sl@0
   907
	{
sl@0
   908
	TVerdict result = EPass;	
sl@0
   909
	//[delete the buffers & Codec]
sl@0
   910
	delete iCodecUnderTest;
sl@0
   911
	delete iGenerator;
sl@0
   912
	delete iSourceData;
sl@0
   913
	delete iCodedData;
sl@0
   914
	delete iRefCodedData;
sl@0
   915
	return result;
sl@0
   916
	}
sl@0
   917
sl@0
   918
/**
sl@0
   919
*
sl@0
   920
* DoTestStepPreambleL
sl@0
   921
* @result TVerdict
sl@0
   922
*
sl@0
   923
*/
sl@0
   924
template <class T, class Generator, TInt index>
sl@0
   925
TVerdict CTestStepSignConversionTest<T, Generator, index>::DoTestStepPreambleL()
sl@0
   926
	{
sl@0
   927
	TVerdict result = EPass;
sl@0
   928
sl@0
   929
	iCodecUnderTest =  new(ELeave) T;   // a cmmfcodec ;
sl@0
   930
	iGenerator = new(ELeave) Generator; // src generator
sl@0
   931
sl@0
   932
  	//[ensure the number of samples is >= srcbuffers]
sl@0
   933
	const TInt KNumBuffers = 2;
sl@0
   934
	const TInt dataSrcSize = KNumBuffers *  iCodecUnderTest->SourceBufferSize();
sl@0
   935
sl@0
   936
	//[generate src data]
sl@0
   937
	iGenerator->GenerateSourceDataL( iSourceData, dataSrcSize);
sl@0
   938
	
sl@0
   939
	const TInt dataSinkSize = KNumBuffers *  iCodecUnderTest->SinkBufferSize();
sl@0
   940
sl@0
   941
	//[generate comparison data]
sl@0
   942
	iGenerator->GenerateComparisonDataL( iRefCodedData, dataSinkSize);
sl@0
   943
sl@0
   944
	//[reserve space for coded data ]
sl@0
   945
    iCodedData = CMMFDescriptorBuffer::NewL(dataSinkSize);
sl@0
   946
sl@0
   947
	return result;
sl@0
   948
	}
sl@0
   949
sl@0
   950
/**
sl@0
   951
*
sl@0
   952
* CTestStepCodecUnitTest
sl@0
   953
*
sl@0
   954
*/
sl@0
   955
template <class T, class Generator, TInt index>
sl@0
   956
CTestStepSignConversionTest<T, Generator, index>::CTestStepSignConversionTest()
sl@0
   957
	{
sl@0
   958
	// store the name of this test case
sl@0
   959
	// this is the name that is used by the script file
sl@0
   960
	iTestStepName = (&KSignConversionParameters[index])->iTestName;
sl@0
   961
	}
sl@0
   962
sl@0
   963
/**
sl@0
   964
*
sl@0
   965
* CTestStepCodecUnitTest
sl@0
   966
*
sl@0
   967
*/
sl@0
   968
template <class T, class Generator, TInt index>
sl@0
   969
CTestStepSignConversionTest<T, Generator, index>::~CTestStepSignConversionTest()
sl@0
   970
	{
sl@0
   971
	}
sl@0
   972
sl@0
   973
/**
sl@0
   974
*
sl@0
   975
* This is used for template instantiation.
sl@0
   976
*
sl@0
   977
**/
sl@0
   978
sl@0
   979
template class CTestStepSignConversionTest<CMMFPcm16ToPcmU8Codec,CMMFPcm16ToPcmU8Generator,0>;
sl@0
   980
template class CTestStepSignConversionTest<CMMFPcm8ToPcm16Codec,CMMFPcm8ToPcm16Generator,1>;
sl@0
   981
template class CTestStepSignConversionTest<CMMFPcm16SwapEndianCodec,CMMFPcmU16toPcmU16BGenerator,2>;
sl@0
   982
template class CTestStepSignConversionTest<CMMFPcm16SwapEndianCodec,CMMFPcmU16BtoPcmU16Generator,3>;
sl@0
   983
template class CTestStepSignConversionTest<CMMFPcmU8ToPcm16Codec,CMMFPcmU8ToPcm16Generator,4>;
sl@0
   984