public FormatBitStream() { huf = new Huffman(); huf.ReadHuffCodeTab(); headerPH = new BitData(32); frameSIPH = new BitData(8); userFrameDataPH = new BitData(16); channelSIPH = new BitData[2]; spectrumSIPH = new BitData[2, 2]; scaleFactorsPH = new BitData[2, 2]; codedDataPH = new BitData[2, 2]; userSpectrumPH = new BitData[2, 2]; for (int ch = 0; ch < 2; ch++) { channelSIPH[ch] = new BitData(16); for (int gr = 0; gr < 2; gr++) { spectrumSIPH[ch, gr] = new BitData(64); scaleFactorsPH[ch, gr] = new BitData(128); codedDataPH[ch, gr] = new BitData(1152); userSpectrumPH[ch, gr] = new BitData(8); } } }
private void WriteBitData(BitData part, byte[] data, ref int pos) { for (int i = 0; i < part.Position; i++) { PutBits(part.Data[i].Value, part.Data[i].Size, data, ref pos); } }
public FrameData(int frameLength, int nGranules, int nChannels, BitData header, BitData frameSI, BitData[] channelSI, BitData[,] spectrumSI, BitData[,] scaleFactors, BitData[,] codedData, BitData[,] userSpectrum, BitData userFrameData) { FrameLength = frameLength; NGranules = nGranules; NChannels = nChannels; Header = header; FrameSI = frameSI; ChannelSI = channelSI; SpectrumSI = spectrumSI; ScaleFactors = scaleFactors; CodedData = codedData; UserSpectrum = userSpectrum; UserFrameData = userFrameData; }
private int WriteMainDataBits(BitData psBH, byte[] data) { int bits = 0; int val; int nBits; int a = 0; if (BitsRemaining == 679) { a = 1; } for (int i = 0; i < psBH.Position; i++) { val = psBH.Data[i].Value; nBits = psBH.Data[i].Size; if (BitsRemaining == 0) { BitsRemaining = WriteHeader(); } if (nBits > BitsRemaining) { nBits -= BitsRemaining; PutBits(val >> nBits, BitsRemaining, data, ref position); BitsRemaining = WriteHeader(); PutBits(val, nBits, data, ref position); } else { PutBits(val, nBits, data, ref position); } BitsRemaining -= nBits; bits += psBH.Data[i].Size; } return(bits); }