NAME
g723_encode g723_decode g723_init_state CCITT G.723 audio
compression and decompression.
SYNOPSIS
#include <multimedia/libaudio.h>
int g723_encode(in_buf, size, header, out_buf, out_size,
void *in_buf;
int size;
Audio_hdr *header;
char *out_buf;
int *out_size;
struct audio_g72x_state *state_ptr;
int g723_decode(in_buf, size, header, out_buf, out_size,
char *in_buf;
int size;
Audio_hdr *header;
void *out_buf;
int *out_size;
struct audio_g72x_state *state_ptr;
void g723_init_state(state_ptr)
struct audio_g72x_state *state_ptr;
DESCRIPTION
These routines implement the CCITT G.723 standard for encod-
ing 16-bit linear PCM or 8-bit u-law or A-law coded audio
data as 3-bit Adaptive Differential Pulse Coded Modulated
(ADPCM) data. It provides 24 Kbps coding for 8KHz audio
data with little degradation in sound quality. The encoding
and decoding routines use a audio_g72x_state structure to
store state information between calls. An audio_g72x_state
structure must be initialized by calling g723_init_state().
This routine should also be used whenever there is a discon-
tinuity in the compressed data stream (for instance, if one
input/output file is closed and another is opened for
decoding/encoding).
The g723_encode() function encodes size bytes of 16-bit
linear PCM or 8-bit u-law or A-law data from the buffer
pointed to by in_buf. The compressed ADPCM data is returned
in out_buf, whose length (in bytes) is returned in out_size.
The data type of the decoded data is specified in the header
structure. state_ptr points to the audio_g72x_state struc-
ture for preserving encoding state. The first 3-bit code is
returned in the least significant bits of the first byte in
the output buffer, while the succeeding code is packed into
the high order bits. Output codes are packed into 3-byte
sample units. In the event that the input buffer does not
contain an even multiple of 3 samples, the extra output
codes are saved in the state structure until the next invo-
cation of g723_encode(). The output buffer specified by
out_buf must contain at least (in_size + 8 ) * 3 / 8 bytes
for u-law and A-law input and ((in_size + 16 ) * 3 / 16
bytes for 16-bit linear input data to accomodate the encoded
data.
After the entire input signal is processed, the remaining
state structure should be flushed by calling g723_encode()
one more time with a in_size argument of zero. out_buf
should refer to a valid output buffer to which up to three
bytes of data may be written. The final output codes are
packed with zeroes, which are harmless when decoded.
The g723_decode() function expands 3-bit ADPCM data into
16-bit linear PCM or 8-bit u-law or A-law format. in_buf
specifies the address of a buffer containing in_size bytes
of 3-bit ADPCM data. Decoded data is stored in the buffer
whose address is given by out_buf. The data type of the
decoded data is specified in the header structure. In the
event that the total number of bits in in_buf is not a mul-
tiple of 3-bit code, the last bits are saved in the state
structure until the next invocation of g723_decode(). The
output buffer must contain enough room to store (8 *
(in_size + 3) / 3) bytes for u-law and A-law data or (16 *
(in_size + 3) / 3) bytes for 16-bit linear PCM data.
state_ptr points to the audio_g72x_state structure for
preserving decoding state. The number of stored output sam-
ples (not bytes!) is returned in out_size.
RETURN VALUE
g723_encode() and g723_decode() return audio error codes or
AUDIO_SUCCESS.
SEE ALSO
audio_711(3), audio_g721(3).
NOTES
These routines comprise an implementation of the 24Kbps
CCITT G.723 ADPCM encoding algorithm. The 40 Kbps G.723
ADPCM, 5 bits per sample, has not been implemented yet.
This implementation has passed the test vectors furnished by
CCITT (Dec. 20, 1988) for u-law and A-law data.
|
Закладки на сайте Проследить за страницей |
Created 1996-2025 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |