180 likes | 381 Views
AMR (Adaptive Multi-Rate]. 작성자 : 박 민 호. What is AMR?. Adaptive Multi-Rate (AMR) is a Audio data compression scheme optimized for speech coding. It has eight bit rates, 12.2, 10.2, 7.95, 7.40, 6.70, 5.90, 5.15 and 4.75 kbit/s.
E N D
AMR(Adaptive Multi-Rate] 작성자 : 박 민 호
What is AMR? • Adaptive Multi-Rate (AMR) is a Audio data compression scheme optimized for speech coding. • It has eight bit rates, 12.2, 10.2, 7.95, 7.40, 6.70, 5.90, 5.15 and 4.75 kbit/s. • The bitstream is based on frames which contain 160 sample and are 20 milliseconds long.
HEADER FRAME 1 FRAME 2 FRAME N Storage format Header contain only a magic number that must consist of ASCII character string: “#!AMR\n” (or 0x2321414d520a)
PCM sample of 20ms (8,000Hz, 16bit, Mono) MR122 : 32byte MR102 : 27byte MR795 : 21byte MR740 : 20byte MR670 : 18byte MR590 : 16byte MR515 : 14byte MR475 : 13byte Encoding Transformation
Rate Information (1byte) Data (Total size of each rate – 1byte) Transformation 20ms Sample ▶160 Sample Data ▶160 * 2byte(16bit) = 320byte Encoding
init_amr function • void init_amr(HANDLE* handle, int dtx) • Retrieve a handle for encode function and decode function. • handle parameter is the pointer to the memory that needed for encoding and decoding process. • dtx parameter is the flag that determine dtx mode. • value 0 : disable dtx mode • value 1 : enable dtx mode • Exampleinit_amr(&h, dtx);
encoder function • int encoder(HANDLE handle, short* inbuf, int inbufSize, unsigned char outbuf, int outbufSize, int mode) • Encode the input data that passed through the inbuf parameter and store the result data into buffer that pointed by outbuf parameter.
encoder function - Parameter • encoder function Parameter • HANDLE handle : Pointer to the memory that allocated for encoding process • short* inbuf : Input data • int inbufSize : Size of input data • unsinged char* outbuf : Pointer to the buffer that will be stored encoded data • int outbufSize : Size of outbuf • int mode : Can choose the rate mode. • MR475 – 0, MR515 – 1, MR590 – 2, MR670 – 3, MR740 – 4, MR795 – 5, MR102 – 6, MR122 - 7
encoder function - Return • Return • Type of result (encoded data) is unsigned char. • Return value • return size of frame that varies as the rate. (refer to slide number 3) • return 0 when initialization of function is succeeded. (refer to next slide) • return -1 when initialization of function is failed on account of that the buffer size of input and output is smaller than requested size. (refer to next slide) • return -2 when input data is processed.
encode function - Remarks • Remarks • Will not be encoded when number of sample is smaller than 160. • The least size of input buffer is 160. • The least size of output buffer is 38. • encoder function need to initialize and return result data from second call that process in blocks of 160 sample.
encoder function - Example • Example Initialization Return result from second call
decoder function • int decoder(HANDLE handle, unsigned char* inbuf, int inbufSize, short* outbuf, int outbufSize) • Decode the input data that passed through the inbuf parameter and store the result data into buffer that pointed by outbuf parameter.
decoder function - Parameter • decoder function Parameter • HANDLE handle : Pointer to the memory that allocated for encoding process • unsigned char* inbuf : Input data • int inbufSize : Size of input data • short* outbuf: Pointer to the buffer that will be stored decoded data • int outbufSize : Size of outbuf
decoder function - Return • Return • Type of result (decoded data) is short. • Return value • return 160 that is size of pcm sample of 20ms long • return 0 when initialization of function is succeeded. (refer to next slide) • return -1 when initialization of function is failed on account of that the buffer size of input and output is smaller than requested size. (refer to next slide) • return -2 when input data is processed.
decoder function - Remarks • Remarks • Will not be decoded when size of frame is smaller than 38. • The least size of input buffer is 38. • The least size of output buffer is 160. • decoder function need to initialize and return result data from second call that process in blocks of frame.
decoder function - Example • Example Initialization Return result from second call
end_amr function • void end_amr(HANDLE handle) • Free memory that allocated by init_amr function.