NAME audio_u2c, audio_u2s, audio_u2l, audio_c2u, audio_s2u, audio_l2u, audio_a2c, audio_a2s, audio_a2l, audio_c2a, audio_s2a, audio_l2a, audio_a2u, audio_u2a - u-law, A-law and linear data conversions SYNOPSIS #include <multimedia/libaudio.h> char audio_u2c(ulaw) unsigned char ulaw; short audio_u2s(ulaw) unsigned char ulaw; long audio_u2l(ulaw) unsigned char ulaw; unsigned char audio_c2u(pcm) char pcm; unsigned char audio_s2u(pcm) short pcm; unsigned char audio_l2u(pcm) long pcm; char audio_a2c(alaw) unsigned char alaw; short audio_a2s(alaw) unsigned char alaw; long audio_a2l(alaw) unsigned char alaw; unsigned char audio_c2a(pcm) char pcm; unsigned char audio_s2a(pcm) short pcm; unsigned char audio_l2a(pcm) long pcm; unsigned char audio_a2u(alaw) unsigned char alaw; unsigned char audio_u2a(ulaw) unsigned char ulaw; DESCRIPTION These macros are designed to make conversions between the 8-bit u-law, A-law and 8-, 16- 32-bit linear Pulse Code Modulated (PCM) values as defined in the CCITT G.711 stan- dards. The u-law and A-law compandings allow linear data to be compressed to 8 bits. All the conversions are imple- mented with lookup tables for fast operations. The u-law and A-law data have 14-bit and 13-bit dynamic ranges respec- tively. Only the most significant bits in the 16- or 32-bit linear PCM values are used for compression and decompres- sion. The u-law and A-law transfer functions result in a nearly linear relationship to PCM at low amplitudes and a loga- rithmic relationship at high amplitudes. Thus, it is not reasonable to perform arithmetic operations (such as would be performed on PCM data) directly on the encoded data. For instance, to sum two u-law or A-law values, the following lines of code will give very different answers: wrong = (ulaw1 + ulaw2); right = audio_s2u(audio_u2s(ulaw1) + audio_u2s(ulaw2)); wrong = (alaw1 + alaw2); right = audio_s2a(audio_a2s(alaw1) + audio_a2s(alaw2)); audio_u2c(), audio_u2s(), and audio_u2l() convert u-law data to PCM signed integers of 8, 16, or 32 bits. audio_a2c(), audio_a2s(), and audio_a2l() convert A-law data to PCM signed integers of 8, 16, or 32 bits. Since u-law and A-law data represents approximately 13 bits of precision to begin with, the conversion to 8-bit integers loses precision, while the conversion to 32-bit integers is provided merely as a convenience. audio_c2u(), audio_s2u(), audio_l2u(), audio_c2a(), audio_s2a(), and audio_l2a() convert 8-, 16-, and 32-bit PCM signed integers to their u-law or A-law encoded form. audio_a2u(), and audio_u2a() do the conversions between u- law and A-law data. Both u-law and A-law data are 8-bit wide. These conversions do not have advantages in compres- sion or arithmetic operations. They are used when an audio file is recorded in one form and played in the other form. SEE ALSO audio_convert(3), audio_g721(3), audio_g723(3).
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |