sl@0: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "MMFAudioMuLawToS16PcmCodec.h" sl@0: sl@0: /*** sl@0: * sl@0: * Convert sl@0: * sl@0: */ sl@0: EXPORT_C void TMMFAudioMuLawToS16PcmCodec::Convert(TUint8* aSrc, TUint8* aDst, TInt aSamples) sl@0: { sl@0: ASSERT(aSrc); sl@0: ASSERT(aDst); sl@0: sl@0: TInt pcm; sl@0: while (aSamples--) sl@0: { sl@0: pcm = MulawSampleToPcm(*aSrc++); sl@0: *aDst++ = STATIC_CAST( TUint8, pcm&KAndMask8bit); sl@0: *aDst++ = STATIC_CAST( TUint8, pcm>>8); sl@0: } sl@0: sl@0: } sl@0: sl@0: /*** sl@0: * sl@0: * MulawSampleToPcm sl@0: * @param aMuLaw sl@0: * @return TInt sl@0: * sl@0: */ sl@0: TInt TMMFAudioMuLawToS16PcmCodec::MulawSampleToPcm(TUint8 aMulaw) sl@0: { sl@0: TInt sign, exponent, mantissa, sample; sl@0: sl@0: aMulaw = STATIC_CAST( TUint8, ~aMulaw); sl@0: sign = ( aMulaw & KMaskSign8bit ); sl@0: exponent = ( aMulaw >> 4 ) & 0x07; sl@0: mantissa = aMulaw & 0x0F; sl@0: sample = KExpLut[exponent] + ( mantissa << ( exponent + 3 ) ); sl@0: if ( sign != 0 ) sl@0: sample = -sample; sl@0: sl@0: return sample; sl@0: } sl@0: sl@0: const TInt TMMFAudioMuLawToS16PcmCodec::KExpLut[KMdaMulawTo16PcmExpLutSize] = sl@0: { sl@0: 0, 132, 396, 924, 1980, 4092, 8316, 16764 sl@0: };