ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

#include <wma.h>

Inheritance diagram for Audio::WMACodec:
Collaboration diagram for Audio::WMACodec:

List of all members.

Public Member Functions

 WMACodec (int version, uint32 sampleRate, uint8 channels, uint32 bitRate, uint32 blockAlign, Common::SeekableReadStream *extraData=0)
 ~WMACodec ()
AudioStreamdecodeFrame (Common::SeekableReadStream &data)

Private Types

typedef Common::Huffman
< Common::BitStream8MSB
HuffmanDecoder

Private Member Functions

void init (Common::SeekableReadStream *extraData)
uint16 getFlags (Common::SeekableReadStream *extraData)
void evalFlags (uint16 flags, Common::SeekableReadStream *extraData)
int getFrameBitLength ()
int getBlockSizeCount (uint16 flags)
uint32 getNormalizedSampleRate ()
bool useNoiseCoding (float &highFreq, float &bps)
void evalMDCTScales (float highFreq)
void initNoise ()
void initCoefHuffman (float bps)
void initMDCT ()
void initExponents ()
HuffmanDecoderinitCoefHuffman (uint16 *&runTable, float *&levelTable, uint16 *&intTable, const WMACoefHuffmanParam &params)
void initLSPToCurve ()
Common::SeekableReadStreamdecodeSuperFrame (Common::SeekableReadStream &data)
bool decodeFrame (Common::BitStream8MSB &bits, int16 *outputData)
int decodeBlock (Common::BitStream8MSB &bits)
bool evalBlockLength (Common::BitStream8MSB &bits)
bool decodeChannels (Common::BitStream8MSB &bits, int bSize, bool msStereo, bool *hasChannel)
bool calculateIMDCT (int bSize, bool msStereo, bool *hasChannel)
void calculateCoefCount (int *coefCount, int bSize) const
bool decodeNoise (Common::BitStream8MSB &bits, int bSize, bool *hasChannel, int *coefCount)
bool decodeExponents (Common::BitStream8MSB &bits, int bSize, bool *hasChannel)
bool decodeSpectralCoef (Common::BitStream8MSB &bits, bool msStereo, bool *hasChannel, int *coefCount, int coefBitCount)
float getNormalizedMDCTLength () const
void calculateMDCTCoefficients (int bSize, bool *hasChannel, int *coefCount, int totalGain, float mdctNorm)
bool decodeExpHuffman (Common::BitStream8MSB &bits, int ch)
bool decodeExpLSP (Common::BitStream8MSB &bits, int ch)
bool decodeRunLevel (Common::BitStream8MSB &bits, const HuffmanDecoder &huffman, const float *levelTable, const uint16 *runTable, int version, float *ptr, int offset, int numCoefs, int blockLen, int frameLenBits, int coefNbBits)
void lspToCurve (float *out, float *val_max_ptr, int n, float *lsp)
void window (float *out) const
 Apply MDCT window and add into output.
float pow_m1_4 (float x) const

Static Private Member Functions

static int readTotalGain (Common::BitStream8MSB &bits)
static int totalGainToBits (int totalGain)
static uint32 getLargeVal (Common::BitStream8MSB &bits)

Private Attributes

int _version
 WMA version.
uint32 _sampleRate
 Output sample rate.
uint8 _channels
 Output channel count.
uint32 _bitRate
 Input bit rate.
uint32 _blockAlign
 Input block align.
byte _audioFlags
 Output flags.
bool _useExpHuffman
 Exponents in Huffman code? Otherwise, in LSP.
bool _useBitReservoir
 Is each frame packet a "superframe"?
bool _useVariableBlockLen
 Are the block lengths variable?
bool _useNoiseCoding
 Should perceptual noise be added?
bool _resetBlockLengths
 Do we need new block lengths?
int _curFrame
 The number of the frame we're currently in.
int _frameLen
 The frame length.
int _frameLenBits
 log2 of the frame length.
int _blockSizeCount
 Number of block sizes.
int _framePos
 The position within the frame we're currently in.
int _curBlock
 The number of the block we're currently in.
int _blockLen
 Current block length.
int _blockLenBits
 log2 of current block length.
int _nextBlockLenBits
 log2 of next block length.
int _prevBlockLenBits
 log2 of previous block length.
int _byteOffsetBits
int _coefsStart
 First coded coef.
int _coefsEnd [kBlockNBSizes]
 Max number of coded coefficients.
int _exponentSizes [kBlockNBSizes]
uint16 _exponentBands [kBlockNBSizes][25]
int _highBandStart [kBlockNBSizes]
 Index of first coef in high band.
int _exponentHighSizes [kBlockNBSizes]
int _exponentHighBands [kBlockNBSizes][kHighBandSizeMax]
HuffmanDecoder_coefHuffman [2]
 Coefficients Huffman codes.
const WMACoefHuffmanParam_coefHuffmanParam [2]
 Params for coef Huffman codes.
uint16_coefHuffmanRunTable [2]
 Run table for the coef Huffman.
float * _coefHuffmanLevelTable [2]
 Level table for the coef Huffman.
uint16_coefHuffmanIntTable [2]
 Int tablre for the coef Huffman.
float _noiseMult
 Noise multiplier.
float _noiseTable [kNoiseTabSize]
 Noise table.
int _noiseIndex
HuffmanDecoder_hgainHuffman
 Perceptual noise huffman code.
int _exponentsBSize [kChannelsMax]
float _exponents [kChannelsMax][kBlockSizeMax]
float _maxExponent [kChannelsMax]
HuffmanDecoder_expHuffman
 Exponents huffman code.
bool _highBandCoded [kChannelsMax][kHighBandSizeMax]
int _highBandValues [kChannelsMax][kHighBandSizeMax]
float _coefs1 [kChannelsMax][kBlockSizeMax]
float _coefs [kChannelsMax][kBlockSizeMax]
float _lspCosTable [kBlockSizeMax]
float _lspPowETable [256]
float _lspPowMTable1 [(1<< kLSPPowBits)]
float _lspPowMTable2 [(1<< kLSPPowBits)]
Common::Array< Common::MDCT * > _mdct
 MDCT contexts.
Common::Array< const float * > _mdctWindow
 MDCT window functions.
byte _lastSuperframe [kSuperframeSizeMax+4]
 Overhang from the last superframe.
int _lastSuperframeLen
 Size of the overhang data. */.
int _lastBitoffset
 Bit position within the overhang. */.
float _output [kBlockSizeMax *2]
float _frameOut [kChannelsMax][kBlockSizeMax *2]

Static Private Attributes

static const int kChannelsMax = 2
 Max number of channels we support.
static const int kBlockBitsMin = 7
 Min number of bits in a block.
static const int kBlockBitsMax = 11
 Max number of bits in a block.
static const int kBlockSizeMax = (1 << kBlockBitsMax)
 Max number of bytes in a block.
static const int kBlockNBSizes = (kBlockBitsMax - kBlockBitsMin + 1)
static const int kSuperframeSizeMax = 16384
 Max size of a superframe.
static const int kHighBandSizeMax = 16
 Max size of a high band.
static const int kNoiseTabSize = 8192
 Size of the noise table.
static const int kLSPPowBits = 7
 Number of bits for the LSP power value.

Detailed Description

Definition at line 44 of file wma.h.


Member Typedef Documentation

Definition at line 113 of file wma.h.


Constructor & Destructor Documentation

Audio::WMACodec::WMACodec ( int  version,
uint32  sampleRate,
uint8  channels,
uint32  bitRate,
uint32  blockAlign,
Common::SeekableReadStream extraData = 0 
)

Definition at line 67 of file wma.cpp.

Audio::WMACodec::~WMACodec (  ) 

Definition at line 106 of file wma.cpp.


Member Function Documentation

void Audio::WMACodec::calculateCoefCount ( int *  coefCount,
int  bSize 
) const [private]

Definition at line 894 of file wma.cpp.

bool Audio::WMACodec::calculateIMDCT ( int  bSize,
bool  msStereo,
bool *  hasChannel 
) [private]

Definition at line 806 of file wma.cpp.

void Audio::WMACodec::calculateMDCTCoefficients ( int  bSize,
bool *  hasChannel,
int *  coefCount,
int  totalGain,
float  mdctNorm 
) [private]

Definition at line 1011 of file wma.cpp.

int Audio::WMACodec::decodeBlock ( Common::BitStream8MSB bits  )  [private]

Definition at line 716 of file wma.cpp.

bool Audio::WMACodec::decodeChannels ( Common::BitStream8MSB bits,
int  bSize,
bool  msStereo,
bool *  hasChannel 
) [private]

Definition at line 769 of file wma.cpp.

bool Audio::WMACodec::decodeExpHuffman ( Common::BitStream8MSB bits,
int  ch 
) [private]

Definition at line 1215 of file wma.cpp.

bool Audio::WMACodec::decodeExpLSP ( Common::BitStream8MSB bits,
int  ch 
) [private]

Definition at line 1313 of file wma.cpp.

bool Audio::WMACodec::decodeExponents ( Common::BitStream8MSB bits,
int  bSize,
bool *  hasChannel 
) [private]

Definition at line 952 of file wma.cpp.

bool Audio::WMACodec::decodeFrame ( Common::BitStream8MSB bits,
int16 outputData 
) [private]

Definition at line 686 of file wma.cpp.

AudioStream * Audio::WMACodec::decodeFrame ( Common::SeekableReadStream data  )  [virtual]

Implements Audio::Codec.

Definition at line 544 of file wma.cpp.

bool Audio::WMACodec::decodeNoise ( Common::BitStream8MSB bits,
int  bSize,
bool *  hasChannel,
int *  coefCount 
) [private]

Definition at line 901 of file wma.cpp.

bool Audio::WMACodec::decodeRunLevel ( Common::BitStream8MSB bits,
const HuffmanDecoder huffman,
const float *  levelTable,
const uint16 runTable,
int  version,
float *  ptr,
int  offset,
int  numCoefs,
int  blockLen,
int  frameLenBits,
int  coefNbBits 
) [private]

Definition at line 1331 of file wma.cpp.

bool Audio::WMACodec::decodeSpectralCoef ( Common::BitStream8MSB bits,
bool  msStereo,
bool *  hasChannel,
int *  coefCount,
int  coefBitCount 
) [private]

Definition at line 975 of file wma.cpp.

Common::SeekableReadStream * Audio::WMACodec::decodeSuperFrame ( Common::SeekableReadStream data  )  [private]

Definition at line 552 of file wma.cpp.

bool Audio::WMACodec::evalBlockLength ( Common::BitStream8MSB bits  )  [private]

Definition at line 825 of file wma.cpp.

void Audio::WMACodec::evalFlags ( uint16  flags,
Common::SeekableReadStream extraData 
) [private]

Definition at line 176 of file wma.cpp.

void Audio::WMACodec::evalMDCTScales ( float  highFreq  )  [private]

Definition at line 310 of file wma.cpp.

int Audio::WMACodec::getBlockSizeCount ( uint16  flags  )  [private]

Definition at line 207 of file wma.cpp.

uint16 Audio::WMACodec::getFlags ( Common::SeekableReadStream extraData  )  [private]

Definition at line 162 of file wma.cpp.

int Audio::WMACodec::getFrameBitLength (  )  [private]

Definition at line 191 of file wma.cpp.

uint32 Audio::WMACodec::getLargeVal ( Common::BitStream8MSB bits  )  [static, private]

Definition at line 1494 of file wma.cpp.

float Audio::WMACodec::getNormalizedMDCTLength (  )  const [private]

Definition at line 1001 of file wma.cpp.

uint32 Audio::WMACodec::getNormalizedSampleRate (  )  [private]

Definition at line 221 of file wma.cpp.

void Audio::WMACodec::init ( Common::SeekableReadStream extraData  )  [private]

Definition at line 122 of file wma.cpp.

void Audio::WMACodec::initCoefHuffman ( float  bps  )  [private]

Definition at line 440 of file wma.cpp.

WMACodec::HuffmanDecoder * Audio::WMACodec::initCoefHuffman ( uint16 *&  runTable,
float *&  levelTable,
uint16 *&  intTable,
const WMACoefHuffmanParam params 
) [private]

Definition at line 479 of file wma.cpp.

void Audio::WMACodec::initExponents (  )  [private]

Definition at line 471 of file wma.cpp.

void Audio::WMACodec::initLSPToCurve (  )  [private]

Definition at line 516 of file wma.cpp.

void Audio::WMACodec::initMDCT (  )  [private]

Definition at line 460 of file wma.cpp.

void Audio::WMACodec::initNoise (  )  [private]

Definition at line 420 of file wma.cpp.

void Audio::WMACodec::lspToCurve ( float *  out,
float *  val_max_ptr,
int  n,
float *  lsp 
) [private]

Definition at line 1284 of file wma.cpp.

float Audio::WMACodec::pow_m1_4 ( float  x  )  const [private]

Definition at line 1453 of file wma.cpp.

int Audio::WMACodec::readTotalGain ( Common::BitStream8MSB bits  )  [static, private]

Definition at line 1473 of file wma.cpp.

int Audio::WMACodec::totalGainToBits ( int  totalGain  )  [static, private]

Definition at line 1486 of file wma.cpp.

bool Audio::WMACodec::useNoiseCoding ( float &  highFreq,
float &  bps 
) [private]

Definition at line 244 of file wma.cpp.

void Audio::WMACodec::window ( float *  out  )  const [private]

Apply MDCT window and add into output.

We ensure that when the windows overlap their squared sum is always 1 (MDCT reconstruction rule).

Definition at line 1406 of file wma.cpp.


Member Data Documentation

Output flags.

Definition at line 81 of file wma.h.

Input bit rate.

Definition at line 79 of file wma.h.

Input block align.

Definition at line 80 of file wma.h.

Current block length.

Definition at line 97 of file wma.h.

log2 of current block length.

Definition at line 98 of file wma.h.

Number of block sizes.

Definition at line 93 of file wma.h.

Definition at line 102 of file wma.h.

Output channel count.

Definition at line 78 of file wma.h.

Coefficients Huffman codes.

Definition at line 114 of file wma.h.

Int tablre for the coef Huffman.

Definition at line 119 of file wma.h.

Level table for the coef Huffman.

Definition at line 118 of file wma.h.

Params for coef Huffman codes.

Definition at line 115 of file wma.h.

Run table for the coef Huffman.

Definition at line 117 of file wma.h.

Definition at line 141 of file wma.h.

Definition at line 140 of file wma.h.

Max number of coded coefficients.

Definition at line 106 of file wma.h.

First coded coef.

Definition at line 105 of file wma.h.

The number of the block we're currently in.

Definition at line 96 of file wma.h.

The number of the frame we're currently in.

Definition at line 90 of file wma.h.

Exponents huffman code.

Definition at line 133 of file wma.h.

Definition at line 108 of file wma.h.

Definition at line 111 of file wma.h.

Definition at line 110 of file wma.h.

Definition at line 130 of file wma.h.

Definition at line 129 of file wma.h.

Definition at line 107 of file wma.h.

The frame length.

Definition at line 91 of file wma.h.

log2 of the frame length.

Definition at line 92 of file wma.h.

Definition at line 160 of file wma.h.

The position within the frame we're currently in.

Definition at line 94 of file wma.h.

Perceptual noise huffman code.

Definition at line 126 of file wma.h.

Definition at line 136 of file wma.h.

Index of first coef in high band.

Definition at line 109 of file wma.h.

Definition at line 137 of file wma.h.

Bit position within the overhang. */.

Definition at line 156 of file wma.h.

Overhang from the last superframe.

Definition at line 154 of file wma.h.

Size of the overhang data. */.

Definition at line 155 of file wma.h.

Definition at line 144 of file wma.h.

float Audio::WMACodec::_lspPowETable[256] [private]

Definition at line 145 of file wma.h.

Definition at line 146 of file wma.h.

Definition at line 147 of file wma.h.

Definition at line 131 of file wma.h.

MDCT contexts.

Definition at line 150 of file wma.h.

Common::Array<const float *> Audio::WMACodec::_mdctWindow [private]

MDCT window functions.

Definition at line 151 of file wma.h.

log2 of next block length.

Definition at line 99 of file wma.h.

Definition at line 124 of file wma.h.

float Audio::WMACodec::_noiseMult [private]

Noise multiplier.

Definition at line 122 of file wma.h.

Noise table.

Definition at line 123 of file wma.h.

Definition at line 159 of file wma.h.

log2 of previous block length.

Definition at line 100 of file wma.h.

Do we need new block lengths?

Definition at line 88 of file wma.h.

Output sample rate.

Definition at line 77 of file wma.h.

Is each frame packet a "superframe"?

Definition at line 84 of file wma.h.

Exponents in Huffman code? Otherwise, in LSP.

Definition at line 83 of file wma.h.

Should perceptual noise be added?

Definition at line 86 of file wma.h.

Are the block lengths variable?

Definition at line 85 of file wma.h.

WMA version.

Definition at line 75 of file wma.h.

const int Audio::WMACodec::kBlockBitsMax = 11 [static, private]

Max number of bits in a block.

Definition at line 56 of file wma.h.

const int Audio::WMACodec::kBlockBitsMin = 7 [static, private]

Min number of bits in a block.

Definition at line 55 of file wma.h.

const int Audio::WMACodec::kBlockNBSizes = (kBlockBitsMax - kBlockBitsMin + 1) [static, private]

Definition at line 61 of file wma.h.

const int Audio::WMACodec::kBlockSizeMax = (1 << kBlockBitsMax) [static, private]

Max number of bytes in a block.

Definition at line 59 of file wma.h.

const int Audio::WMACodec::kChannelsMax = 2 [static, private]

Max number of channels we support.

Definition at line 53 of file wma.h.

const int Audio::WMACodec::kHighBandSizeMax = 16 [static, private]

Max size of a high band.

Definition at line 67 of file wma.h.

const int Audio::WMACodec::kLSPPowBits = 7 [static, private]

Number of bits for the LSP power value.

Definition at line 73 of file wma.h.

const int Audio::WMACodec::kNoiseTabSize = 8192 [static, private]

Size of the noise table.

Definition at line 70 of file wma.h.

const int Audio::WMACodec::kSuperframeSizeMax = 16384 [static, private]

Max size of a superframe.

Definition at line 64 of file wma.h.


The documentation for this class was generated from the following files:


Generated on Sat May 25 2019 05:04:51 for ResidualVM by doxygen 1.7.1
curved edge   curved edge