AMR decoding corrupting the heap

Login to reply to this topic.
Mon, 2005-02-07 13:16
Joined: 2004-11-08
Forum posts: 22
Hi,
I am converting AMR data to raw PCM into descriptor. Since descriptor things are not working using CMdaAudioConvertutility(known issue in this forum), I started to use older version of AMR decoder using CAmrToPcmDecoder. The decoding process goes fine but certain issues comes after that. here it goes:
1. After the decoding ( AMR to PCM ) completes the first few 25-30 bytes always show data as 00. I didn't get the reason why?

2. After the decoding completes the program heap gets corrupted. I am not able to create a single object after decoding is completed. This is a major problem which is stopping my work. Could anyone give advice on this?

I am using symbian 7.0 s60 2.1

here is a code snippet.

   TInt opbufsize = 0;
   TInt i = 0;
   TInt j = 0;
   TInt ipoff =0;
   TInt opoff = 0;

   TDes8* outputBuff = new(ELeave) TBuf8<500>;
   outputBuff->SetMax();
   TUint8 *opBuff = (TUint8*)(outputBuff->Ptr());

   TAmrDecParams decodeparams;
   CAmrToPcmDecoder *decoder = CAmrToPcmDecoder::NewL(decodeparams);
   
   
   TUint8 *ipBuff = (TUint8*)(aAmrbuf->Ptr());

TInt availbaleblock;
TInt heaplen;
   User::Check();
   heaplen= User::Available(availbaleblock);
   TInt err = 0;
while(ipbufsize>0)
   {
   err = decoder->Decode(ipBuff + ipoff, i, opBuff + opoff, j, EFalse);
   ipoff = ipoff + i;
   opoff = opoff + j;
   ipbufsize = ipbufsize - i;
   opbufsize = opbufsize + j;
   }

// Note: **************************************
//  The decoder is corrupting the heap. Heap Check is failing.
/// **************************************
   User::Check();
   heaplen= User::Available(availbaleblock);

   HBufC8 *buf;
   buf = HBufC8::NewL(500);

   User::Check();
   heaplen= User::Available(availbaleblock);

-void*

Thu, 2005-07-07 15:11
Joined: 2005-04-09
Forum posts: 29
Re: AMR decoding corrupting the heap
how can i write it into a file, is there anything i have to care, as big endian little endian problems?

i tried the code, used 13 bytes(frame size from FrameInfo() function, 4.75 kbps amr) buffers to read from amr file, 320 bytes buffers are occured after Decode(),
i sent them to a RPointerArray, then after all the buffers of amr processed, i wrote the array elements to a file from 0 to end.
then i tried to play it with decodertest example (http://forum.newlc.com/index.php?topic=968.0) which plays popular testing123.raw successfully.

am i doing a silly mistake?
i'm at the end of the way with CAmrToPcmDecoder, i have no idea about what the problem is, and it's really hard to find a documentation about the class and how it works,

any help and link is really appreciated
Wed, 2005-07-13 04:18
Joined: 2005-05-31
Forum posts: 7
Re: AMR decoding corrupting the heap
I doing some work of converting amr data into pcm16 too.

but i can't find the class CAmrToPcmDecoder, is there any document that introduce it?

i am using symbian 7.0s sdk2.1.

wait for you reply, thank you!
Wed, 2005-07-13 06:57
Joined: 2005-04-09
Forum posts: 29
Re: AMR decoding corrupting the heap
it is coming with the Series60 1.2 sdk, and's it's removed from the 2.1 sdk, but the related dlls are still placed on devices, at least for Nokia 6600, it's so.
to work on it in 2.1 sdk, it's enough to copy the amrcodec.h from sdk 1.2 to 2.1 and the dll of cource amrdll.lib,
but i must warn you, there is a huge lack of documentation about the class
Tue, 2005-08-23 12:32
Joined: 2004-09-15
Forum posts: 9
Re: AMR decoding corrupting the heap
void*
Hmm, I'm using CPcmToAmrDecoder in same way and have no prolems with thread's heap. Maybe, you're using incorrect amrdll library?
Mon, 2005-09-12 07:24
Joined: 2005-07-16
Forum posts: 127
Re: AMR decoding corrupting the heap
Hi,

You can use the following way to convert amr to pcm. It works perfectly.

const TInt KPcmBufferSize = 320;
const TInt KAmrBufferSize = 32;

void ConstractL()
{
   iPcm16Buffer = CMMFDescriptorBuffer::NewL(KPcmBufferSize);
   iAmrBuffer = CMMFDescriptorBuffer::NewL(KAmrBufferSize);
}

void CStreamPlayEngine::ConvertAmr2PcmL(const TDesC8& aAmrData,TDes8& aDestBuffer)
{
   iAmrBuffer->Data().Copy(aAmrData);

   TBool OkMai(EFalse);

   TCodecProcessResult result = iOCodec->ProcessL(*iAmrBuffer,*iPcm16Buffer);

   if((result.iStatus == TCodecProcessResult::EProcessComplete))
   {
      OkMai = ETrue;
      aDestBuffer.Copy(iPcm16Buffer->Data());
   }
}
  • Login to reply to this topic.