dmG722Encode(3dm) dmG722Encode(3dm)
dmG722Encode - implements the ITU (International Telecommunication Union)
Recommendation G.722 compression.
#include <dmedia/dm_audioutil.h>
DMstatus dmG722Encode(DMG722encoder handle,
short *ibuf, unsigned char *obuf, int nsamples)
handle DMG722encoder structure, created by dmG722EncoderCreate(3dm),
specifies the signal processing parameters.
ibuf pointer to input sample data buffer. The data format is short
(16-bit). The samples are assumed to be two's complement.
Sampling rate must be 16 kHz or less.
obuf pointer to output data buffer. The data format is unsigned
char (8-bit).
nsamples number of samples in the input buffer to be processed. the
value of nsamples passed to the G.722 encode/decode routines
must always be a multiple of 2. It will fail if nsamples
exceeds the the maximum value specified when the DMG722encoder
was created.
Returns DM_FAILURE or DM_SUCCESS.
dmG722Encode(3dm) implements the ITU Recommendation G.722 compression.
If sampling rate is less than 16 kHz, the algorithm still works, except
the upper bits contains less useful information.
dmG722Encode(3dm) algorithm uses bandpass filter operations that convolve
past input samples with a filter M-coefficient array. The linear phase
filter has a constant time delay of G = (M-1)/2 samples.
dmG722Decode(3dm) algorithm also uses bandpass filter operations. The
total delay for operating dmG722Encode(3dm) and dmG722Decode(3dm) will be
2*G = M-1 samples. This constant is _AU_G722_QMF_DELAY, which is 23.
Page 1
dmG722Encode(3dm) dmG722Encode(3dm)
In real time operation, bandpass filtering simply delays the output by 23
samples. In file conversion expecting N samples in and out, the output
signal is offset by 23 samples from the first sample. The application
may want to discard the first 23 samples returned in output date buffer
from dmG722Decode. The application may also want to flush out an
additional 23 samples from dmG722Encode after feeding in all the input
data to be compressed. This flushing operation is performed by calling
dmG722Encode with a value nsamples = 23 (the corresponding inbuf will
typically be bzero'd).
ITU Recommendation G.722 compression also uses a linear prediction
scheme. This means that the compressed bits, which carrying compressed
information, are interrelated or interdependent. If a application calls
afSeekFrame() to an offset into the compressed bit stream file and then
starts reading bits in the middle of the bit stream and decompress them
with dmG722Decode(3dm), the interdependency of the bits at the cutting
point is lost. The application will initially get back data with a lower
amplitude than if he had read the same data back during a complete pass
over the file from the beginning.
There is no way to exactly recreate the decoded data in the middle of the
bit stream file without going all the way back to the beginning.
However, with a "preroll" value to read ahead a portion of the compressed
file, application can compensate for the amplitude problem. We recommend
2 second "preroll". The application may also consider adding extra 23
samples for "preroll" for compensation of the filter delays encountered
in the encoding and decoding processes, as we discussed above.
G.722 algorithm was developed for sampling rate of 16 kHz.
dmG722EncoderCreate(3dm), dmG722EncoderDestroy(3dm), dmG722Decode(3dm),
ITU Recommendation G.722.
PPPPaaaaggggeeee 2222 [ Back ]
|