×

Discussion Board

Results 1 to 2 of 2

Hybrid View

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    4

    PCM to AMR conversion problem

    Hi,
    I am working on audio streaming for Nokia 6630 in Symbian 8.0. I am trying to convert the PCM samples to AMR using the following code:

    // Uid of PCM16toAMR codec is 0x101FAF68
    CMMFCodec* codec = CMMFCodec::NewL(TUid::Uid(0x101FAF68));
    CleanupStack::PushL(codec);
    CMMFDescriptorBuffer* srcbuf = CMMFDescriptorBuffer::NewL(320);
    CleanupStack::PushL(srcbuf);
    CMMFDescriptorBuffer* dstbuf = CMMFDescriptorBuffer::NewL(32);
    CleanupStack::PushL(dstbuf);
    TCodecProcessResult result;
    srcbuf->Data().Copy(*iStreamBuffer[iStreamIdx]); //Copy your PCM frame data into srcbuf, for example:
    result = codec->ProcessL(*srcbuf, *dstbuf);
    (*iEncBuffer[iStreamIdx]).Copy(dstbuf->Data()); //Copy the AMR data into the buffer

    CleanupStack::PopAndDestroy(dstbuf);
    CleanupStack::PopAndDestroy(srcbuf);
    CleanupStack::PopAndDestroy(codec);

    Again AMR to PCM conversion i use the same code with UID 0x101FAF67.
    I give 320 bytes of PCM sample for conversion but I get only 13 bytes encoded AMR data. Again when I pass this 13 bytes, the AMR to PCM conversion gives 32 bytes which i feel it is wrong. When I play these samples i get a garbage sound. Can anyone tell me where I went wrong? Help needed urgently over this...
    I want to know what AMR encoding rate is used.

    kavitha

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037
    Hi,

    you probably have some errors in your decompressing code, when I decode AMR back to PCM I use this if statement to ensure that conversion was succesfull:

    if ( ( result.iStatus == TCodecProcessResult::EProcessComplete ) &&
    ( result.iSrcBytesProcessed == KAmrFrameSize ) &&
    ( result.iDstBytesAdded == KPcmBufferSize ) )
    {
    // return buffer
    return &( iPcm16Buffer->Data() );
    }

    Both constants are defined as
    // raw buffer size
    #define KPcmBufferSize 320

    // amr frame size
    #define KAmrFrameSize 13

    So the ratio 320:13 is ok, using 32 bytes buffer only waste 19 bytes Are you sure that you use the correct codec uid for converting from amr to pcm??
    #define KAdvancedUidCodecAMRToPCM16 0x101FAF67
    If you have still problems put your amr2pcm16 code here, so i should look on it
    Bye
    STEN

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •