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 #include "MMFAudioSPcm16ToALawCodec.h"
23 EXPORT_C void TMMFAudioSPcm16ToAlawCodec::Convert(TUint8* aSrc, TUint8* aDst, TInt aSamples)
25 TInt16* pcm = (TInt16*)aSrc;
26 TInt16* pcmLimit = pcm + aSamples;
28 while (pcm < pcmLimit)
30 *aDst++ = PcmSampleToAlaw(*pcm++);
35 //[ conversion look up table pcm16 to alaw ]
36 const TInt8 TMMFAudioSPcm16ToAlawCodec::KExpLut[] =
63 TUint8 TMMFAudioSPcm16ToAlawCodec::PcmSampleToAlaw(TInt aPcm)
70 sign = ((~aPcm) >> 8) & KMaskSign8bit;
73 if (aPcm > KMda16PcmToAlawClip)
74 aPcm = KMda16PcmToAlawClip;
78 exponent = KExpLut[( aPcm >> 8 ) & 0x7F];
79 mantissa = ( aPcm >> ( exponent + 3 ) ) & 0x0F;
80 alawbyte = STATIC_CAST( TUint8, (( exponent << 4 ) | mantissa));
83 alawbyte = STATIC_CAST( TUint8, aPcm >> 4);
85 alawbyte ^= (sign ^ 0x55);