xoreos  0.0.5
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Sound::WMACodec Class Reference
Inheritance diagram for Sound::WMACodec:
Inheritance graph
[legend]
Collaboration diagram for Sound::WMACodec:
Collaboration graph
[legend]

Public Member Functions

 WMACodec (int version, uint32 sampleRate, uint8 channels, uint32 bitRate, uint32 blockAlign, Common::SeekableReadStream *extraData=0)
 
 ~WMACodec ()
 
int getChannels () const
 Return the number channels in this stream. More...
 
int getRate () const
 Sample rate of the stream. More...
 
bool endOfData () const
 End of data reached? If this returns true, it means that at this time there is no data available in the stream. More...
 
bool endOfStream () const
 End of stream reached? If this returns true, it means that all data in this stream is used up and no additional data will appear in it in the future. More...
 
size_t readBuffer (int16 *buffer, const size_t numSamples)
 Fill the given buffer with up to numSamples samples. More...
 
void finish ()
 Mark this stream as finished. More...
 
bool isFinished () const
 Is the stream marked as finished? More...
 
void queuePacket (Common::SeekableReadStream *data)
 Queue the next packet to be decoded. More...
 
- Public Member Functions inherited from Sound::PacketizedAudioStream
virtual ~PacketizedAudioStream ()
 
- Public Member Functions inherited from Sound::AudioStream
virtual ~AudioStream ()
 

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 ()
 
Common::HuffmaninitCoefHuffman (Common::ScopedArray< uint16 > &runTable, Common::ScopedArray< float > &levelTable, Common::ScopedArray< uint16 > &intTable, const WMACoefHuffmanParam &params)
 
void initLSPToCurve ()
 
Common::SeekableReadStreamdecodeSuperFrame (Common::SeekableReadStream &data)
 
bool decodeFrame (Common::BitStream &bits, int16 *outputData)
 
int decodeBlock (Common::BitStream &bits)
 
AudioStreamdecodeFrame (Common::SeekableReadStream &data)
 
bool evalBlockLength (Common::BitStream &bits)
 
bool decodeChannels (Common::BitStream &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::BitStream &bits, int bSize, bool *hasChannel, int *coefCount)
 
bool decodeExponents (Common::BitStream &bits, int bSize, bool *hasChannel)
 
bool decodeSpectralCoef (Common::BitStream &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::BitStream &bits, int ch)
 
bool decodeExpLSP (Common::BitStream &bits, int ch)
 
bool decodeRunLevel (Common::BitStream &bits, const Common::Huffman &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. More...
 
float pow_m1_4 (float x) const
 

Static Private Member Functions

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

Private Attributes

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

Static Private Attributes

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

Additional Inherited Members

- Static Public Attributes inherited from Sound::AudioStream
static const size_t kSizeInvalid = SIZE_MAX
 

Detailed Description

Definition at line 103 of file wma.cpp.

Constructor & Destructor Documentation

◆ WMACodec()

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

◆ ~WMACodec()

Sound::WMACodec::~WMACodec ( )

Definition at line 328 of file wma.cpp.

Member Function Documentation

◆ calculateCoefCount()

void Sound::WMACodec::calculateCoefCount ( int *  coefCount,
int  bSize 
) const
private

Definition at line 1100 of file wma.cpp.

References _channels, _coefsEnd, and _coefsStart.

Referenced by decodeChannels().

Here is the caller graph for this function:

◆ calculateIMDCT()

bool Sound::WMACodec::calculateIMDCT ( int  bSize,
bool  msStereo,
bool *  hasChannel 
)
private

Definition at line 1012 of file wma.cpp.

References _blockLen, _channels, _coefs, _frameLen, _frameOut, _framePos, _mdct, _output, Common::MDCT::calcIMDCT(), and window().

Referenced by decodeBlock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateMDCTCoefficients()

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

◆ decodeBlock()

int Sound::WMACodec::decodeBlock ( Common::BitStream bits)
private

Definition at line 922 of file wma.cpp.

References _blockLen, _blockLenBits, _blockSizeCount, _channels, _curBlock, _frameLen, _frameLenBits, _framePos, calculateIMDCT(), decodeChannels(), evalBlockLength(), Common::BitStream::getBit(), and kChannelsMax.

Referenced by decodeFrame().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decodeChannels()

bool Sound::WMACodec::decodeChannels ( Common::BitStream bits,
int  bSize,
bool  msStereo,
bool *  hasChannel 
)
private

Definition at line 975 of file wma.cpp.

References _blockLen, _coefs, Sound::butterflyFloats(), calculateCoefCount(), calculateMDCTCoefficients(), decodeExponents(), decodeNoise(), decodeSpectralCoef(), getNormalizedMDCTLength(), kChannelsMax, readTotalGain(), and totalGainToBits().

Referenced by decodeBlock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decodeExpHuffman()

bool Sound::WMACodec::decodeExpHuffman ( Common::BitStream bits,
int  ch 
)
private

Definition at line 1423 of file wma.cpp.

References _blockLen, _blockLenBits, _expHuffman, _exponentBands, _exponents, _frameLenBits, _maxExponent, _version, ARRAYSIZE, Common::BitStream::getBits(), Sound::powTab, warning(), and XOREOS_FALLTHROUGH.

Referenced by decodeExponents().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decodeExpLSP()

bool Sound::WMACodec::decodeExpLSP ( Common::BitStream bits,
int  ch 
)
private

Definition at line 1523 of file wma.cpp.

References _blockLen, _exponents, _maxExponent, Common::BitStream::getBits(), Sound::kLSPCoefCount, Sound::lspCodebook, and lspToCurve().

Referenced by decodeExponents().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decodeExponents()

bool Sound::WMACodec::decodeExponents ( Common::BitStream bits,
int  bSize,
bool *  hasChannel 
)
private

Definition at line 1158 of file wma.cpp.

References _blockLenBits, _channels, _exponentsBSize, _frameLenBits, _useExpHuffman, decodeExpHuffman(), decodeExpLSP(), and Common::BitStream::getBit().

Referenced by decodeChannels().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decodeFrame() [1/2]

bool Sound::WMACodec::decodeFrame ( Common::BitStream bits,
int16 outputData 
)
private

Definition at line 892 of file wma.cpp.

References _channels, _curBlock, _curFrame, _frameLen, _frameOut, _framePos, decodeBlock(), Sound::floatToInt16Interleave(), and kChannelsMax.

Referenced by decodeSuperFrame(), and queuePacket().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decodeFrame() [2/2]

AudioStream * Sound::WMACodec::decodeFrame ( Common::SeekableReadStream data)
private

Definition at line 751 of file wma.cpp.

References _audioFlags, _channels, _sampleRate, decodeSuperFrame(), and Sound::makePCMStream().

Here is the call graph for this function:

◆ decodeNoise()

bool Sound::WMACodec::decodeNoise ( Common::BitStream bits,
int  bSize,
bool *  hasChannel,
int *  coefCount 
)
private

Definition at line 1107 of file wma.cpp.

References _channels, _exponentHighBands, _exponentHighSizes, _hgainHuffman, _highBandCoded, _highBandValues, _useNoiseCoding, Common::BitStream::getBit(), Common::BitStream::getBits(), and warning().

Referenced by decodeChannels().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decodeRunLevel()

bool Sound::WMACodec::decodeRunLevel ( Common::BitStream bits,
const Common::Huffman 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 1541 of file wma.cpp.

References Common::BitStream::getBit(), Common::BitStream::getBits(), getLargeVal(), Common::Huffman::getSymbol(), and warning().

Referenced by decodeSpectralCoef().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decodeSpectralCoef()

bool Sound::WMACodec::decodeSpectralCoef ( Common::BitStream bits,
bool  msStereo,
bool *  hasChannel,
int *  coefCount,
int  coefBitCount 
)
private

Definition at line 1181 of file wma.cpp.

References _blockLen, _channels, _coefHuffman, _coefHuffmanLevelTable, _coefHuffmanRunTable, _coefs1, _frameLenBits, _version, decodeRunLevel(), Common::BitStream::pos(), and Common::BitStream::skip().

Referenced by decodeChannels().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decodeSuperFrame()

Common::SeekableReadStream * Sound::WMACodec::decodeSuperFrame ( Common::SeekableReadStream data)
private

◆ endOfData()

bool Sound::WMACodec::endOfData ( ) const
inlinevirtual

End of data reached? If this returns true, it means that at this time there is no data available in the stream.

However there may be more data in the future. This is used by e.g. a rate converter to decide whether to keep on converting data or stop.

Implements Sound::AudioStream.

Definition at line 112 of file wma.cpp.

References _audStream.

◆ endOfStream()

bool Sound::WMACodec::endOfStream ( ) const
inlinevirtual

End of stream reached? If this returns true, it means that all data in this stream is used up and no additional data will appear in it in the future.

This is used by the mixer to decide whether a given stream shall be removed from the list of active streams (and thus be destroyed). By default this maps to endOfData()

Reimplemented from Sound::AudioStream.

Definition at line 113 of file wma.cpp.

References _audStream.

◆ evalBlockLength()

bool Sound::WMACodec::evalBlockLength ( Common::BitStream bits)
private

Definition at line 1031 of file wma.cpp.

References _blockLen, _blockLenBits, _blockSizeCount, _frameLen, _frameLenBits, _framePos, _nextBlockLenBits, _prevBlockLenBits, _resetBlockLengths, _useVariableBlockLen, Common::BitStream::getBits(), Common::intLog2(), and warning().

Referenced by decodeBlock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evalFlags()

void Sound::WMACodec::evalFlags ( uint16  flags,
Common::SeekableReadStream extraData 
)
private

Definition at line 385 of file wma.cpp.

References _useBitReservoir, _useExpHuffman, _useVariableBlockLen, _version, Common::ReadStream::readUint16LE(), Common::SeekableReadStream::seek(), and Common::SeekableReadStream::size().

Referenced by init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evalMDCTScales()

void Sound::WMACodec::evalMDCTScales ( float  highFreq)
private

◆ finish()

void Sound::WMACodec::finish ( )
inlinevirtual

Mark this stream as finished.

That is, signal that no further data will be queued to it. Only after this has been done can this stream ever 'end'.

Implements Sound::PacketizedAudioStream.

Definition at line 117 of file wma.cpp.

References _audStream.

◆ getBlockSizeCount()

int Sound::WMACodec::getBlockSizeCount ( uint16  flags)
private

Definition at line 416 of file wma.cpp.

References _bitRate, _channels, _frameLenBits, _useVariableBlockLen, kBlockBitsMin, and MIN().

Referenced by init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getChannels()

int Sound::WMACodec::getChannels ( ) const
inlinevirtual

Return the number channels in this stream.

Implements Sound::AudioStream.

Definition at line 110 of file wma.cpp.

References _channels.

Referenced by WMACodec().

Here is the caller graph for this function:

◆ getFlags()

uint16 Sound::WMACodec::getFlags ( Common::SeekableReadStream extraData)
private

Definition at line 371 of file wma.cpp.

References _version, Common::ReadStream::readUint16LE(), Common::SeekableReadStream::seek(), and Common::SeekableReadStream::size().

Referenced by init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFrameBitLength()

int Sound::WMACodec::getFrameBitLength ( )
private

Definition at line 400 of file wma.cpp.

References _sampleRate, and _version.

Referenced by init().

Here is the caller graph for this function:

◆ getLargeVal()

uint32 Sound::WMACodec::getLargeVal ( Common::BitStream bits)
staticprivate

Definition at line 1701 of file wma.cpp.

References Common::BitStream::getBit(), and Common::BitStream::getBits().

Referenced by decodeRunLevel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNormalizedMDCTLength()

float Sound::WMACodec::getNormalizedMDCTLength ( ) const
private

Definition at line 1207 of file wma.cpp.

References _blockLen, and _version.

Referenced by decodeChannels().

Here is the caller graph for this function:

◆ getNormalizedSampleRate()

uint32 Sound::WMACodec::getNormalizedSampleRate ( )
private

Definition at line 430 of file wma.cpp.

References _sampleRate, and _version.

Referenced by useNoiseCoding().

Here is the caller graph for this function:

◆ getRate()

int Sound::WMACodec::getRate ( ) const
inlinevirtual

Sample rate of the stream.

Implements Sound::AudioStream.

Definition at line 111 of file wma.cpp.

References _sampleRate.

Referenced by WMACodec().

Here is the caller graph for this function:

◆ init()

void Sound::WMACodec::init ( Common::SeekableReadStream extraData)
private

◆ initCoefHuffman() [1/2]

void Sound::WMACodec::initCoefHuffman ( float  bps)
private

Definition at line 648 of file wma.cpp.

References _coefHuffman, _coefHuffmanIntTable, _coefHuffmanLevelTable, _coefHuffmanParam, _coefHuffmanRunTable, _sampleRate, Sound::coefHuffmanParam, and Common::ScopedPtrBase< T, Deallocator >::reset().

Referenced by init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initCoefHuffman() [2/2]

Common::Huffman * Sound::WMACodec::initCoefHuffman ( Common::ScopedArray< uint16 > &  runTable,
Common::ScopedArray< float > &  levelTable,
Common::ScopedArray< uint16 > &  intTable,
const WMACoefHuffmanParam params 
)
private

◆ initExponents()

void Sound::WMACodec::initExponents ( )
private

Definition at line 679 of file wma.cpp.

References _expHuffman, _useExpHuffman, ARRAYSIZE, initLSPToCurve(), Common::ScopedPtrBase< T, Deallocator >::reset(), Sound::scaleHuffBits, and Sound::scaleHuffCodes.

Referenced by init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initLSPToCurve()

void Sound::WMACodec::initLSPToCurve ( )
private

Definition at line 723 of file wma.cpp.

References _frameLen, _lspCosTable, _lspPowETable, _lspPowMTable1, _lspPowMTable2, kLSPPowBits, and M_PI.

Referenced by initExponents().

Here is the caller graph for this function:

◆ initMDCT()

void Sound::WMACodec::initMDCT ( )
private

Definition at line 668 of file wma.cpp.

References _blockSizeCount, _frameLenBits, _mdct, _mdctWindow, and Common::getSineWindow().

Referenced by init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initNoise()

void Sound::WMACodec::initNoise ( )
private

Definition at line 629 of file wma.cpp.

References _hgainHuffman, _noiseIndex, _noiseMult, _noiseTable, _useExpHuffman, _useNoiseCoding, ARRAYSIZE, Sound::hgainHuffBits, Sound::hgainHuffCodes, kNoiseTabSize, and Common::ScopedPtrBase< T, Deallocator >::reset().

Referenced by init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isFinished()

bool Sound::WMACodec::isFinished ( ) const
inlinevirtual

Is the stream marked as finished?

Implements Sound::PacketizedAudioStream.

Definition at line 118 of file wma.cpp.

References _audStream.

◆ lspToCurve()

void Sound::WMACodec::lspToCurve ( float *  out,
float *  val_max_ptr,
int  n,
float *  lsp 
)
private

Definition at line 1494 of file wma.cpp.

References _lspCosTable, Sound::kLSPCoefCount, and pow_m1_4().

Referenced by decodeExpLSP().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pow_m1_4()

float Sound::WMACodec::pow_m1_4 ( float  x) const
private

Definition at line 1660 of file wma.cpp.

References _lspPowETable, _lspPowMTable1, _lspPowMTable2, and kLSPPowBits.

Referenced by lspToCurve().

Here is the caller graph for this function:

◆ queuePacket()

void Sound::WMACodec::queuePacket ( Common::SeekableReadStream data)
virtual

Queue the next packet to be decoded.

Implements Sound::PacketizedAudioStream.

Definition at line 1719 of file wma.cpp.

References _audStream, and decodeFrame().

Here is the call graph for this function:

◆ readBuffer()

size_t Sound::WMACodec::readBuffer ( int16 buffer,
const size_t  numSamples 
)
inlinevirtual

Fill the given buffer with up to numSamples samples.

Returns the actual number of samples read, or kSizeInvalid if a critical error occurred (note: you must check if this value is less than what you requested, this can happen when the stream is fully used up).

Data has to be in native endianness, 16 bit per sample, signed. For stereo stream, buffer will be filled with interleaved left and right channel samples, starting with a left sample. Furthermore, the samples in the left and right are summed up. So if you request 4 samples from a stereo stream, you will get a total of two left channel and two right channel samples.

The same holds true for more channels. Channel configurations recognized:

  • 5.1: front left, front right, front center, low frequency rear left, rear right

Implements Sound::AudioStream.

Definition at line 114 of file wma.cpp.

References _audStream.

◆ readTotalGain()

int Sound::WMACodec::readTotalGain ( Common::BitStream bits)
staticprivate

Definition at line 1680 of file wma.cpp.

References Common::BitStream::getBits().

Referenced by decodeChannels().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ totalGainToBits()

int Sound::WMACodec::totalGainToBits ( int  totalGain)
staticprivate

Definition at line 1693 of file wma.cpp.

Referenced by decodeChannels().

Here is the caller graph for this function:

◆ useNoiseCoding()

bool Sound::WMACodec::useNoiseCoding ( float &  highFreq,
float &  bps 
)
private

Definition at line 453 of file wma.cpp.

References _channels, _sampleRate, and getNormalizedSampleRate().

Referenced by init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ window()

void Sound::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 1613 of file wma.cpp.

References _blockLen, _blockLenBits, _frameLenBits, _mdctWindow, _nextBlockLenBits, _output, _prevBlockLenBits, Sound::vectorFMulAdd(), and Sound::vectorFMulReverse().

Referenced by calculateIMDCT().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _audioFlags

byte Sound::WMACodec::_audioFlags
private

Output flags.

Definition at line 150 of file wma.cpp.

Referenced by decodeFrame(), and WMACodec().

◆ _audStream

Common::ScopedPtr<QueuingAudioStream> Sound::WMACodec::_audStream
private

Definition at line 232 of file wma.cpp.

Referenced by endOfData(), endOfStream(), finish(), isFinished(), queuePacket(), readBuffer(), and WMACodec().

◆ _bitRate

uint32 Sound::WMACodec::_bitRate
private

Input bit rate.

Definition at line 148 of file wma.cpp.

Referenced by getBlockSizeCount(), and init().

◆ _blockAlign

uint32 Sound::WMACodec::_blockAlign
private

Input block align.

Definition at line 149 of file wma.cpp.

Referenced by decodeSuperFrame().

◆ _blockLen

int Sound::WMACodec::_blockLen
private

◆ _blockLenBits

int Sound::WMACodec::_blockLenBits
private

log2 of current block length.

Definition at line 167 of file wma.cpp.

Referenced by calculateMDCTCoefficients(), decodeBlock(), decodeExpHuffman(), decodeExponents(), evalBlockLength(), and window().

◆ _blockSizeCount

int Sound::WMACodec::_blockSizeCount
private

Number of block sizes.

Definition at line 162 of file wma.cpp.

Referenced by decodeBlock(), evalBlockLength(), evalMDCTScales(), init(), and initMDCT().

◆ _byteOffsetBits

int Sound::WMACodec::_byteOffsetBits
private

Definition at line 171 of file wma.cpp.

Referenced by decodeSuperFrame(), and init().

◆ _channels

uint8 Sound::WMACodec::_channels
private

◆ _coefHuffman

Common::ScopedPtr<Common::Huffman> Sound::WMACodec::_coefHuffman[2]
private

Coefficients Huffman codes.

Definition at line 182 of file wma.cpp.

Referenced by decodeSpectralCoef(), and initCoefHuffman().

◆ _coefHuffmanIntTable

Common::ScopedArray<uint16> Sound::WMACodec::_coefHuffmanIntTable[2]
private

Int table for the coef Huffman.

Definition at line 188 of file wma.cpp.

Referenced by initCoefHuffman().

◆ _coefHuffmanLevelTable

Common::ScopedArray<float> Sound::WMACodec::_coefHuffmanLevelTable[2]
private

Level table for the coef Huffman.

Definition at line 187 of file wma.cpp.

Referenced by decodeSpectralCoef(), and initCoefHuffman().

◆ _coefHuffmanParam

const WMACoefHuffmanParam* Sound::WMACodec::_coefHuffmanParam[2]
private

Params for coef Huffman codes.

Definition at line 184 of file wma.cpp.

Referenced by initCoefHuffman(), and WMACodec().

◆ _coefHuffmanRunTable

Common::ScopedArray<uint16> Sound::WMACodec::_coefHuffmanRunTable[2]
private

Run table for the coef Huffman.

Definition at line 186 of file wma.cpp.

Referenced by decodeSpectralCoef(), and initCoefHuffman().

◆ _coefs

float Sound::WMACodec::_coefs[kChannelsMax][kBlockSizeMax]
private

Definition at line 210 of file wma.cpp.

Referenced by calculateIMDCT(), calculateMDCTCoefficients(), and decodeChannels().

◆ _coefs1

float Sound::WMACodec::_coefs1[kChannelsMax][kBlockSizeMax]
private

Definition at line 209 of file wma.cpp.

Referenced by calculateMDCTCoefficients(), and decodeSpectralCoef().

◆ _coefsEnd

int Sound::WMACodec::_coefsEnd[kBlockNBSizes]
private

Max number of coded coefficients.

Definition at line 175 of file wma.cpp.

Referenced by calculateCoefCount(), calculateMDCTCoefficients(), and evalMDCTScales().

◆ _coefsStart

int Sound::WMACodec::_coefsStart
private

First coded coef.

Definition at line 174 of file wma.cpp.

Referenced by calculateCoefCount(), calculateMDCTCoefficients(), and evalMDCTScales().

◆ _curBlock

int Sound::WMACodec::_curBlock
private

The number of the block we're currently in.

Definition at line 165 of file wma.cpp.

Referenced by decodeBlock(), and decodeFrame().

◆ _curFrame

int Sound::WMACodec::_curFrame
private

The number of the frame we're currently in.

Definition at line 159 of file wma.cpp.

Referenced by decodeFrame(), and decodeSuperFrame().

◆ _expHuffman

Common::ScopedPtr<Common::Huffman> Sound::WMACodec::_expHuffman
private

Exponents Huffman code.

Definition at line 202 of file wma.cpp.

Referenced by decodeExpHuffman(), and initExponents().

◆ _exponentBands

uint16 Sound::WMACodec::_exponentBands[kBlockNBSizes][25]
private

Definition at line 177 of file wma.cpp.

Referenced by decodeExpHuffman(), and evalMDCTScales().

◆ _exponentHighBands

int Sound::WMACodec::_exponentHighBands[kBlockNBSizes][kHighBandSizeMax]
private

Definition at line 180 of file wma.cpp.

Referenced by calculateMDCTCoefficients(), decodeNoise(), and evalMDCTScales().

◆ _exponentHighSizes

int Sound::WMACodec::_exponentHighSizes[kBlockNBSizes]
private

Definition at line 179 of file wma.cpp.

Referenced by calculateMDCTCoefficients(), decodeNoise(), and evalMDCTScales().

◆ _exponents

float Sound::WMACodec::_exponents[kChannelsMax][kBlockSizeMax]
private

Definition at line 199 of file wma.cpp.

Referenced by calculateMDCTCoefficients(), decodeExpHuffman(), and decodeExpLSP().

◆ _exponentsBSize

int Sound::WMACodec::_exponentsBSize[kChannelsMax]
private

Definition at line 198 of file wma.cpp.

Referenced by calculateMDCTCoefficients(), and decodeExponents().

◆ _exponentSizes

int Sound::WMACodec::_exponentSizes[kBlockNBSizes]
private

Definition at line 176 of file wma.cpp.

Referenced by evalMDCTScales().

◆ _frameLen

int Sound::WMACodec::_frameLen
private

◆ _frameLenBits

int Sound::WMACodec::_frameLenBits
private

◆ _frameOut

float Sound::WMACodec::_frameOut[kChannelsMax][kBlockSizeMax *2]
private

Definition at line 229 of file wma.cpp.

Referenced by calculateIMDCT(), decodeFrame(), and init().

◆ _framePos

int Sound::WMACodec::_framePos
private

The position within the frame we're currently in.

Definition at line 163 of file wma.cpp.

Referenced by calculateIMDCT(), decodeBlock(), decodeFrame(), and evalBlockLength().

◆ _hgainHuffman

Common::ScopedPtr<Common::Huffman> Sound::WMACodec::_hgainHuffman
private

Perceptual noise Huffman code.

Definition at line 195 of file wma.cpp.

Referenced by decodeNoise(), and initNoise().

◆ _highBandCoded

bool Sound::WMACodec::_highBandCoded[kChannelsMax][kHighBandSizeMax]
private

Definition at line 205 of file wma.cpp.

Referenced by calculateMDCTCoefficients(), and decodeNoise().

◆ _highBandStart

int Sound::WMACodec::_highBandStart[kBlockNBSizes]
private

Index of first coef in high band.

Definition at line 178 of file wma.cpp.

Referenced by calculateMDCTCoefficients(), and evalMDCTScales().

◆ _highBandValues

int Sound::WMACodec::_highBandValues[kChannelsMax][kHighBandSizeMax]
private

Definition at line 206 of file wma.cpp.

Referenced by calculateMDCTCoefficients(), and decodeNoise().

◆ _lastBitoffset

int Sound::WMACodec::_lastBitoffset
private

Bit position within the overhang.

Definition at line 225 of file wma.cpp.

Referenced by decodeSuperFrame().

◆ _lastSuperframe

byte Sound::WMACodec::_lastSuperframe[kSuperframeSizeMax+4]
private

Overhang from the last superframe.

Definition at line 223 of file wma.cpp.

Referenced by decodeSuperFrame().

◆ _lastSuperframeLen

int Sound::WMACodec::_lastSuperframeLen
private

Size of the overhang data.

Definition at line 224 of file wma.cpp.

Referenced by decodeSuperFrame().

◆ _lspCosTable

float Sound::WMACodec::_lspCosTable[kBlockSizeMax]
private

Definition at line 213 of file wma.cpp.

Referenced by initLSPToCurve(), and lspToCurve().

◆ _lspPowETable

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

Definition at line 214 of file wma.cpp.

Referenced by initLSPToCurve(), and pow_m1_4().

◆ _lspPowMTable1

float Sound::WMACodec::_lspPowMTable1[(1<< kLSPPowBits)]
private

Definition at line 215 of file wma.cpp.

Referenced by initLSPToCurve(), and pow_m1_4().

◆ _lspPowMTable2

float Sound::WMACodec::_lspPowMTable2[(1<< kLSPPowBits)]
private

Definition at line 216 of file wma.cpp.

Referenced by initLSPToCurve(), and pow_m1_4().

◆ _maxExponent

float Sound::WMACodec::_maxExponent[kChannelsMax]
private

Definition at line 200 of file wma.cpp.

Referenced by calculateMDCTCoefficients(), decodeExpHuffman(), and decodeExpLSP().

◆ _mdct

Common::PtrVector<Common::MDCT> Sound::WMACodec::_mdct
private

MDCT contexts.

Definition at line 219 of file wma.cpp.

Referenced by calculateIMDCT(), and initMDCT().

◆ _mdctWindow

std::vector<const float *> Sound::WMACodec::_mdctWindow
private

MDCT window functions.

Definition at line 220 of file wma.cpp.

Referenced by initMDCT(), and window().

◆ _nextBlockLenBits

int Sound::WMACodec::_nextBlockLenBits
private

log2 of next block length.

Definition at line 168 of file wma.cpp.

Referenced by evalBlockLength(), and window().

◆ _noiseIndex

int Sound::WMACodec::_noiseIndex
private

Definition at line 193 of file wma.cpp.

Referenced by calculateMDCTCoefficients(), and initNoise().

◆ _noiseMult

float Sound::WMACodec::_noiseMult
private

Noise multiplier.

Definition at line 191 of file wma.cpp.

Referenced by calculateMDCTCoefficients(), and initNoise().

◆ _noiseTable

float Sound::WMACodec::_noiseTable[kNoiseTabSize]
private

Noise table.

Definition at line 192 of file wma.cpp.

Referenced by calculateMDCTCoefficients(), and initNoise().

◆ _output

float Sound::WMACodec::_output[kBlockSizeMax *2]
private

Definition at line 228 of file wma.cpp.

Referenced by calculateIMDCT(), init(), and window().

◆ _prevBlockLenBits

int Sound::WMACodec::_prevBlockLenBits
private

log2 of previous block length.

Definition at line 169 of file wma.cpp.

Referenced by evalBlockLength(), and window().

◆ _resetBlockLengths

bool Sound::WMACodec::_resetBlockLengths
private

Do we need new block lengths?

Definition at line 157 of file wma.cpp.

Referenced by decodeSuperFrame(), and evalBlockLength().

◆ _sampleRate

uint32 Sound::WMACodec::_sampleRate
private

◆ _useBitReservoir

bool Sound::WMACodec::_useBitReservoir
private

Is each frame packet a "superframe"?

Definition at line 153 of file wma.cpp.

Referenced by decodeSuperFrame(), and evalFlags().

◆ _useExpHuffman

bool Sound::WMACodec::_useExpHuffman
private

Exponents in Huffman code? Otherwise, in LSP.

Definition at line 152 of file wma.cpp.

Referenced by decodeExponents(), evalFlags(), initExponents(), and initNoise().

◆ _useNoiseCoding

bool Sound::WMACodec::_useNoiseCoding
private

Should perceptual noise be added?

Definition at line 155 of file wma.cpp.

Referenced by calculateMDCTCoefficients(), decodeNoise(), init(), and initNoise().

◆ _useVariableBlockLen

bool Sound::WMACodec::_useVariableBlockLen
private

Are the block lengths variable?

Definition at line 154 of file wma.cpp.

Referenced by evalBlockLength(), evalFlags(), and getBlockSizeCount().

◆ _version

int Sound::WMACodec::_version
private

◆ kBlockBitsMax

const int Sound::WMACodec::kBlockBitsMax = 11
staticprivate

Max number of bits in a block.

Definition at line 125 of file wma.cpp.

◆ kBlockBitsMin

const int Sound::WMACodec::kBlockBitsMin = 7
staticprivate

Min number of bits in a block.

Definition at line 124 of file wma.cpp.

Referenced by evalMDCTScales(), and getBlockSizeCount().

◆ kBlockNBSizes

const int Sound::WMACodec::kBlockNBSizes = (kBlockBitsMax - kBlockBitsMin + 1)
staticprivate

Definition at line 130 of file wma.cpp.

◆ kBlockSizeMax

const int Sound::WMACodec::kBlockSizeMax = (1 << kBlockBitsMax)
staticprivate

Max number of bytes in a block.

Definition at line 128 of file wma.cpp.

◆ kChannelsMax

const int Sound::WMACodec::kChannelsMax = 2
staticprivate

Max number of channels we support.

Definition at line 122 of file wma.cpp.

Referenced by decodeBlock(), decodeChannels(), decodeFrame(), and WMACodec().

◆ kHighBandSizeMax

const int Sound::WMACodec::kHighBandSizeMax = 16
staticprivate

Max size of a high band.

Definition at line 136 of file wma.cpp.

Referenced by calculateMDCTCoefficients().

◆ kLSPPowBits

const int Sound::WMACodec::kLSPPowBits = 7
staticprivate

Number of bits for the LSP power value.

Definition at line 142 of file wma.cpp.

Referenced by initLSPToCurve(), and pow_m1_4().

◆ kNoiseTabSize

const int Sound::WMACodec::kNoiseTabSize = 8192
staticprivate

Size of the noise table.

Definition at line 139 of file wma.cpp.

Referenced by calculateMDCTCoefficients(), and initNoise().

◆ kSuperframeSizeMax

const int Sound::WMACodec::kSuperframeSizeMax = 16384
staticprivate

Max size of a superframe.

Definition at line 133 of file wma.cpp.


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