confused with AMR format
| Thu, 2005-07-07 17:12 | |
|
|
i'm trying to convert amr to pcm, i'm a little confused about amr format
what i know is so; 1 frame = 160 sample = 20 ms. i'm trying to use CAmrToPcmDecoder class to decode amr, FrameInfo() function says frame size = 13 byte for a 4.75 kbits/s amr. then; 1 frame = 13 byte = 104 bits = 20 ms 1 sn = 1000 ms = 50 frame = 5200 bits the bit rate value got by FrameInfo() is 5200 also isn't it supposed to be 4750? i'am really confused. |






Forum posts: 16
There you can find that the number of AMR core bits for 4.75 kbps is 95 which matches the 4.75 kbps.
On top of the core AMR bits there are container formats like IF1 or IF2 (octet format with padding) .These have information regarding the mode, CRC etc and this accounts for the extra bits that you see.
Forum posts: 76
AMR encoding can be used in bandwidth efficient mode, where data is packed bit-by-bit with no waste at all.
The bit-rate stated in the encoding mode (e.g. AMR 4.75Kbits/s) refers to the number of bits of actual audio data per second generated. There is also a 4-bit header added onto each 20ms frame encoded that boosts the bit-rate up a bit more.
You will not normally see bandwidth efficient AMR mode in use. In practise you will always see octet (i.e. byte) aligned mode. Under this scheme, the bits of each 20ms frame are packed into a whole number of bytes and padded on the end with zeroes (if there is any space left over). Also, the 4-bit header for each frame is expanded to a 1-byte header. The 4-bits of interest lie in the top 4 bits of this byte. The lower 4 bits are reserved and are not used.
So, to calculate byte size of a frame in octet-aligned mode AMR, perform the following simple calculation:
E.g. AMR 4.75Kbits/s:
Number of audio bits generated per second = 4750bits/s
Number of audio bits generated per 20ms frame = 4750bits/s / 50frames/s = 95bits
Number of bytes to hold one 20ms frame = 95bits / 8bits/byte = 11.875bytes - round this up to 12-bytes and pad the data with zeroes
Add 1-byte for the header, making one 20ms frame of AMR 4.75KBits/s = 12-bytes + 1-byte = 13-bytes
Working back again, this equates to 13-bytes * 50frames/s * 8bits/byte = 5200bits/s
Voila!
Hope this helps
Regards
Andy
Forum posts: 127
void ConvertAmr2PcmL(const TDesC8& aAmrData,TDes8& aDestBuffer)
{
iAmrBuffer->Data().Copy(aAmrData);
TBool OkMai(EFalse);
//TAmrEncParams params;
//params.iMode = 0;
//iOCodec->ConfigureL(TUid::Uid(0x101FAF67),(const TDesC8&)params );
TCodecProcessResult result = iOCodec->ProcessL(*iAmrBuffer,*iPcm16Buffer);
if((result.iStatus == TCodecProcessResult::EProcessComplete))
{
OkMai = ETrue;
aDestBuffer.Copy(iPcm16Buffer->Data());
}
else
{
// should we report error.
}
}