Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

IMA_ADPCM Class Reference
[Audio Codec - IMA ADPCM]

#include <IMA_ADPCM.h>

List of all members.


Detailed Description

A class which implements the IMA ADPCM audio coding algorithm.

Typically, IMA ADPCM data is stored as blocks of data with the PredictedValue and StepIndex values held in a header to each block. When decoding, these values should be writen to this class to initialise the decoding of a block. When encoding, these values should be writen out to a block's header prior to encoding the samples in the block.

Note, when IMA ADPCM data is stored in Microsoft WAV files, the PredictedValue found in the block's header is used as the first sample for that block. The first ADPCM value in the block's data then represents the second sample.

Version:
2006-05-20

Definition at line 56 of file IMA_ADPCM.h.

Public Member Functions

IMPORT void EncodeInit (int16_t sample1, int16_t sample2)
IMPORT unsigned Encode (int16_t pcm16)
IMPORT int Decode (unsigned adpcm)
IMPORT unsigned Encode (uint8_t *dst, int dstOffset, const int16_t *src, size_t srcSize)
IMPORT unsigned Decode (int16_t *dst, const uint8_t *src, int srcOffset, unsigned srcSize)

Public Attributes

int16_t PredictedValue
uint8_t StepIndex


Member Function Documentation

EXPORT void IMA_ADPCM::EncodeInit int16_t  sample1,
int16_t  sample2
 

Initialise the PredictedValue and StepIndex members to the optimum values for encoding an audio stream whoes first two PCM samples have the values given. Use of this method at the start of audio stream encoding gives improved accuracy over a naive initialisation which sets PredictedValue and StepIndex to predetermined constant values.

Parameters:
sample1 The first PCM sample in the audio stream.
sample2 The second PCM sample in the audio stream.

Definition at line 59 of file IMA_ADPCM.cpp.

EXPORT unsigned IMA_ADPCM::Encode int16_t  pcm16  ) 
 

Encode a single linear PCM sample as an ADPCM value.

Parameters:
pcm16 The PCM value to encode.
Returns:
The 4 least significan bits represent the encoded ADPCM value. Other bits are zero.
Postcondition:
PredictedValue and StepIndex are updated ready for encoding the next sample.

Definition at line 74 of file IMA_ADPCM.cpp.

EXPORT int IMA_ADPCM::Decode unsigned  adpcm  ) 
 

Decode a single ADPCM value into a 16bit linear PCM value.

Parameters:
adpcm The 4 least significan bits represent ADPCM value to encode. Other bits are ignored.
Returns:
The decoded 16 bit PCM value sign extended to an int.
Postcondition:
PredictedValue and StepIndex are updated ready for decoding the next sample.

Definition at line 132 of file IMA_ADPCM.cpp.

EXPORT unsigned IMA_ADPCM::Encode uint8_t dst,
int  dstOffset,
const int16_t src,
size_t  srcSize
 

Encode a buffer of 16 bit uniform PCM values into ADPCM values.

Two ADPCM values are stored in each byte. The value stored in bits 0-3 corresponds to the sample preceding that stored in bits 4-7. Note, if the last encoded ADPCM value is stored in bits 0-3, then bits 4-7 will be cleared to zero.

Parameters:
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. The value of dstOffset must be a multiple of 4.
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 2.
Returns:
The number of bits which were stored at dst.

Definition at line 167 of file IMA_ADPCM.cpp.

EXPORT unsigned IMA_ADPCM::Decode int16_t dst,
const uint8_t src,
int  srcOffset,
unsigned  srcSize
 

Decode a buffer of ADPCM values into 16 bit uniform PCM values.

Two ADPCM values are stored in each byte. The value stored in bits 0-3 corresponds to the sample preceding that stored in bits 4-7.

Parameters:
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. The value of srcOffset must be a multiple of 4.
srcSize The number of bits to be read from the buffer at src. Must be a multiple of the size of 4.
Returns:
The number of bytes which were stored at dst.

Definition at line 204 of file IMA_ADPCM.cpp.


Member Data Documentation

int16_t IMA_ADPCM::PredictedValue
 

The predicted value of the next sample. Typically, this value is read from the header, or written to the header, of a block of ADPCM values.

Definition at line 152 of file IMA_ADPCM.h.

uint8_t IMA_ADPCM::StepIndex
 

The step index used for the next ADPCM value Typically, this value is read from the header, or written to the header, of a block of ADPCM values.

Definition at line 159 of file IMA_ADPCM.h.


The documentation for this class was generated from the following files:
Generated by  doxygen 1.4.4