25 #ifndef AUDIO_DECODERS_WMA_H 26 #define AUDIO_DECODERS_WMA_H 28 #include "common/array.h" 29 #include "common/bitstream.h" 31 #include "audio/decoders/codec.h" 34 template <
class BITSTREAM>
44 struct WMACoefHuffmanParam;
48 WMACodec(
int version, uint32 sampleRate, uint8 channels,
55 static const int kChannelsMax = 2;
57 static const int kBlockBitsMin = 7;
58 static const int kBlockBitsMax = 11;
61 static const int kBlockSizeMax = (1 << kBlockBitsMax);
63 static const int kBlockNBSizes = (kBlockBitsMax - kBlockBitsMin + 1);
66 static const int kSuperframeSizeMax = 16384;
69 static const int kHighBandSizeMax = 16;
72 static const int kNoiseTabSize = 8192;
75 static const int kLSPPowBits = 7;
86 bool _useBitReservoir;
87 bool _useVariableBlockLen;
90 bool _resetBlockLengths;
101 int _nextBlockLenBits;
102 int _prevBlockLenBits;
108 int _coefsEnd[kBlockNBSizes];
109 int _exponentSizes[kBlockNBSizes];
110 uint16 _exponentBands[kBlockNBSizes][25];
111 int _highBandStart[kBlockNBSizes];
112 int _exponentHighSizes[kBlockNBSizes];
113 int _exponentHighBands[kBlockNBSizes][kHighBandSizeMax];
116 HuffmanDecoder *_coefHuffman[2];
119 uint16 *_coefHuffmanRunTable[2];
120 float *_coefHuffmanLevelTable[2];
121 uint16 *_coefHuffmanIntTable[2];
125 float _noiseTable[kNoiseTabSize];
128 HuffmanDecoder *_hgainHuffman;
131 int _exponentsBSize[kChannelsMax];
132 float _exponents[kChannelsMax][kBlockSizeMax];
133 float _maxExponent[kChannelsMax];
135 HuffmanDecoder *_expHuffman;
138 bool _highBandCoded [kChannelsMax][kHighBandSizeMax];
139 int _highBandValues[kChannelsMax][kHighBandSizeMax];
142 float _coefs1[kChannelsMax][kBlockSizeMax];
143 float _coefs [kChannelsMax][kBlockSizeMax];
146 float _lspCosTable[kBlockSizeMax];
147 float _lspPowETable[256];
148 float _lspPowMTable1[(1 << kLSPPowBits)];
149 float _lspPowMTable2[(1 << kLSPPowBits)];
156 byte _lastSuperframe[kSuperframeSizeMax + 4];
157 int _lastSuperframeLen;
161 float _output[kBlockSizeMax * 2];
162 float _frameOut[kChannelsMax][kBlockSizeMax * 2];
171 int getFrameBitLength();
172 int getBlockSizeCount(uint16 flags);
173 uint32 getNormalizedSampleRate();
174 bool useNoiseCoding(
float &highFreq,
float &bps);
175 void evalMDCTScales(
float highFreq);
177 void initCoefHuffman(
float bps);
179 void initExponents();
181 HuffmanDecoder *initCoefHuffman(uint16 *&runTable,
float *&levelTable,
183 void initLSPToCurve();
195 bool calculateIMDCT(
int bSize,
bool msStereo,
bool *hasChannel);
197 void calculateCoefCount(
int *coefCount,
int bSize)
const;
201 int *coefCount,
int coefBitCount);
202 float getNormalizedMDCTLength()
const;
203 void calculateMDCTCoefficients(
int bSize,
bool *hasChannel,
204 int *coefCount,
int totalGain,
float mdctNorm);
209 const float *levelTable,
const uint16 *runTable,
int version,
float *ptr,
210 int offset,
int numCoefs,
int blockLen,
int frameLenBits,
int coefNbBits);
212 void lspToCurve(
float *out,
float *val_max_ptr,
int n,
float *lsp);
214 void window(
float *out)
const;
216 float pow_m1_4(
float x)
const;
219 static int totalGainToBits(
int totalGain);
225 #endif // AUDIO_DECODERS_WMA_H
Definition: bitstream.h:55
Definition: algorithm.h:29
Definition: audiostream.h:50
Definition: wmadata.h:1345