A class which implements ITU-T (formerly CCITT) Recomendation G726 "40, 32, 24, 16 kbit/s Adaptive Differential Pulse Code Modulation (ADPCM)". More...
#include <G726.h>
Public Types | |
| enum | Law { uLaw = 0, ALaw = 1, PCM16 = 2 } |
| enum | Rate { Rate16kBits = 2, Rate24kBits = 3, Rate32kBits = 4, Rate40kBits = 5 } |
Public Member Functions | |
| G726 () | |
| void | Reset () |
| void | SetLaw (Law law) |
| void | SetRate (Rate rate) |
| unsigned | Encode (unsigned pcm) |
| unsigned | Decode (unsigned adpcm) |
| unsigned | Encode (void *dst, int dstOffset, const void *src, size_t srcSize) |
| unsigned | Decode (void *dst, const void *src, int srcOffset, unsigned srcSize) |
Private Member Functions | |
| void | InputPCMFormatConversionAndDifferenceSignalComputation (unsigned S, int SE, int &D) |
| FIGURE 4/G.726 from Section 4.2.1 - Input PCM format conversion and difference signal computation. | |
| void | AdaptiveQuantizer (int D, unsigned Y, unsigned &I) |
| FIGURE 5/G.726 from Section 4.2.2 - Adaptive quantizer. | |
| void | InverseAdaptiveQuantizer (unsigned I, unsigned Y, unsigned &DQ) |
| FIGURE 6/G.726 from Section 4.2.3 - Inverse adaptive quantizer. | |
| void | QuantizerScaleFactorAdaptation1 (unsigned AL, unsigned &Y) |
| FIGURE 7/G.726 (Part 1) from Section 4.2.4 - Quantizer scale factor adaptation. | |
| void | QuantizerScaleFactorAdaptation2 (unsigned I, unsigned Y) |
| FIGURE 7/G.726 (Part 2) from Section 4.2.4 - Quantizer scale factor adaptation. | |
| void | AdaptationSpeedControl1 (unsigned &AL) |
| FIGURE 8/G.726 (Part 1) from Section 4.2.5 - Adaptation speed control. | |
| void | AdaptationSpeedControl2 (unsigned I, unsigned y, unsigned TDP, unsigned TR) |
| FIGURE 8/G.726 (Part 2) from Section 4.2.5 - Adaptation speed control. | |
| void | AdaptativePredictorAndReconstructedSignalCalculator1 (int &SE, int &SEZ) |
| FIGURE 9/G.726 (Part1) from Section 4.2.6 - Adaptative predictor and reconstructed signal calculator. | |
| void | AdaptativePredictorAndReconstructedSignalCalculator2 (unsigned DQ, unsigned TR, int SE, int SEZ, int &SR, int &A2P) |
| FIGURE 9/G.726 (Part2) from Section 4.2.6 - Adaptative predictor and reconstructed signal calculator. | |
| void | ToneAndTransitionDetector1 (unsigned DQ, unsigned &TR) |
| FIGURE 10/G.726 (Part 1) from Section 4.2.7 - Tone and transition detector. | |
| void | ToneAndTransitionDetector2 (int A2P, unsigned TR, unsigned &TDP) |
| FIGURE 10/G.726 (Part 2) from Section 4.2.7 - Tone and transition detector. | |
| void | OutputPCMFormatConversionAndSynchronousCodingAdjustment (int SR, int SE, unsigned Y, unsigned I, unsigned &SD) |
| FIGURE 11/G.726 from Section 4.2.8 - Output PCM format conversion and synchronous coding adjustment. | |
| void | DifferenceSignalComputation (int SL, int SE, int &D) |
| FIGURE A.4/G.726 from Section A.3.3 - Difference signal computation. | |
| void | OutputLimiting (int SR, int &S0) |
| FIGURE A.5/G.726 from Section A.3.5 - Output limiting (decoder only). | |
| unsigned | EncodeDecode (unsigned input, bool encode) |
| The top level method which implements the complete algorithm for both encoding and decoding. | |
A class which implements ITU-T (formerly CCITT) Recomendation G726 "40, 32, 24, 16 kbit/s Adaptive Differential Pulse Code Modulation (ADPCM)".
G726 replaces recomendations G721 and G723.
Note, this implemetation reproduces bugs found in the G191 reference implementation of G726. These bugs can be controlled by the IMPLEMENT_G191_BUGS macro.
Definition at line 62 of file G726.h.
| enum G726::Law |
| enum G726::Rate |
| G726::G726 | ( | ) |
| void G726::Reset | ( | ) |
| void G726::SetLaw | ( | Law | law | ) |
| void G726::SetRate | ( | Rate | rate | ) |
| unsigned G726::Encode | ( | unsigned | pcm | ) |
Encodes a single PCM value as an ADPCM value.
| pcm | The PCM value to encode. The bits in this value which lie outside the range of values for the currently set encoding law, are ignored. |
| unsigned G726::Decode | ( | unsigned | adpcm | ) |
Decodes a single ADPCM value into a PCM value.
| adpcm | The ADPCM value to decode. The bits in this value which lie outside the range of values for the currently set bit-rate, are ignored. |
| unsigned G726::Encode | ( | void * | dst, | |
| int | dstOffset, | |||
| const void * | src, | |||
| size_t | srcSize | |||
| ) |
Encode a buffer of uniform PCM values into ADPCM values.
Each ADPCM value only occupies the minimum number of bits required and successive values occupy adjacent bit positions. E.g. Four 3 bit ADPCM values (A,B,C,D) are stored in two successive bytes like this: 1st byte: ccbbbaaa 2nd byte: ----dddc. Note that any unused bits in the last byte are set to zero.
| dst | Pointer to location to store ADPCM values. | |
| dstOffset | Offset from dst, in number-of-bits, at which the decoded values will be stored. I.e. the least significant bit of the first ADPCM value will be stored in byte
dst[dstOffset>>3] at bit position dstOffset&7 Where the bit 0 is the least significant bit in a byte and bit 7 is the most significant bit. | |
| src | Pointer to the buffer of PCM values to be converted. | |
| srcSize | The size in bytes of the buffer at src. Must be a multiple of the size of a single PCM sample. |
| unsigned G726::Decode | ( | void * | dst, | |
| const void * | src, | |||
| int | srcOffset, | |||
| unsigned | srcSize | |||
| ) |
Decode a buffer of ADPCM values into uniform PCM values.
Each ADPCM value only occupies the minimum number of bits required and successive values occupy adjacent bit positions. E.g. Four 3 bit ADPCM values (A,B,C,D) are stored in two successive bytes like this: 1st byte: ccbbbaaa 2nd byte: ----dddc.
| dst | Pointer to location to store PCM values. | |
| src | Pointer to the buffer of ADPCM values to be converted. | |
| srcOffset | Offset from src, in number-of-bits, from which the ADPCM values will be read. I.e. the least significant bit of the first ADPCM value will be read from byte
src[srcOffset>>3] at bit position srcOffset&7 Where the bit 0 is the least significant bit in a byte and bit 7 is the most significant bit. | |
| srcSize | The number of bits to be read from the buffer at src. Must be a multiple of the size of a single ADPCM value. |
| unsigned G726::EncodeDecode | ( | unsigned | input, | |
| bool | encode | |||
| ) | [private] |
The top level method which implements the complete algorithm for both encoding and decoding.
| input | Either the PCM input to the encoder or the ADPCM input to the decoder. | |
| encode | A flag which if true makes this method perform the encode function. If the flag is false then the decode function is performed. |
1.6.1