First public contribution.
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 "MMFAudioALawToS16PcmCodec.h"
23 EXPORT_C void TMMFAudioALawToS16PcmCodec::Convert(TUint8* aSrc, TUint8* aDst, TInt aSamples)
31 pcm = AlawSampleToPcm(*aSrc++);
32 *aDst++ = STATIC_CAST( TUint8, pcm&KAndMask8bit);
33 *aDst++ = STATIC_CAST( TUint8, pcm>>8);
45 TInt TMMFAudioALawToS16PcmCodec::AlawSampleToPcm(TUint8 aAlaw)
47 TInt sign, exponent, mantissa, sample;
49 aAlaw ^= 0x55; //will leave this as is, more readable
50 sign = ( aAlaw & KMaskSign8bit );
51 aAlaw &= 0x7f; /* get magnitude */
54 exponent = (aAlaw >> 4 ) & 0x07;
55 mantissa = aAlaw & 0x0F;
56 sample = KExpLut[exponent] + ( mantissa << ( exponent + 3 ) );
59 sample = (aAlaw << 4) + 8;
67 const TInt TMMFAudioALawToS16PcmCodec::KExpLut[] =
69 0, 264, 528, 1056, 2112, 4224, 8448, 16896