AMR File Format:
AMR( AdaptiveMultiRate ) is an audio format which is extensively used in mobile devices in various applications ranging from normal audio player/recorder to VoIP kind of applications. AMR can be further categorized as
1) AMR-NB( NarrowBand )
2) AMR-WB( WideBand )
But in general terms, AMR refers to AMR-NB. The AMR file format (*.amr) has the following structure:
Each AMR file consists of a 6-byte header that identifies the file as AMR audio. This header is always set to: 0x23, 0x21, 0x41, 0x4D, 0x52, 0x0A. This is common across all AMR-NB files. If the header is not as it should be, the file is probably corrupted and should not be used.
From here( ie. from the 7th byte ) the AMR file consists of a whole number of packed frames of audio (into bandwidth inefficient, octet-aligned mode ). These frames each constitute 20ms of audio. Each frame can be encoded using any of the valid AMR-NB modes (0-7, 8 SID in DTX mode). Because the frames can be encoded at different rates, this method of encoding is called Adaptive Multi-Rate(AMR).
Each frame can be encoded using one of 8 varying levels of compression using various bitrates(AMR modes 0-7). Following are the various AMR modes and their corresponding bitrates:
MODE BIT RATES 0 - AMR 4.75 - Encodes at 4.75kbit/s 1 - AMR 5.15 - Encodes at 5.15kbit/s 2 - AMR 5.9 - Encodes at 5.9kbit/s 3 - AMR 6.7 - Encodes at 6.7kbit/s 4 - AMR 7.4 - Encodes at 7.4kbit/s 5 - AMR 7.95 - Encodes at 7.95kbit/s 6 - AMR 10.2 - Encodes at 10.2kbit/s 7 - AMR 12.2 - Encodes at 12.2kbit/s
Each frame consists of a 1-byte header, then the rest of the frame is audio data. The entire frame is fed into the AMR decoder (header too). The frame size can be deduced from the frame header.
The 2nd bit through 5th bit (counting the most significant bit as the first bit) comprise the CMR (Codec Mode Request), values 0-7 being valid for AMR. The top bit of the CMR can actually be ignored, though it is used when AMR forms RTP payloads. The lower 3-bits of the header are reserved and are not used. Viewing the header from most significant bit to least significant bit, the encoding is XCCCCXXX, where Xs are reserved (typically 0) and the Cs are the CMR.
Frame size of AMR modes in bytes (including the header byte) are shown below:
CMR MODE FRAME SIZE( in bytes ) 0 AMR 4.75 13 1 AMR 5.15 14 2 AMR 5.9 16 3 AMR 6.7 18 4 AMR 7.4 20 5 AMR 7.95 21 6 AMR 10.2 27 7 AMR 12.2 32
The above frame specifications and header information applies only for AMR-NB and the frame format might be different for AMR-WB.